1

I'm currently working in my Android app. and so far I got to the point where I need my app. to view some videos for the user initially I thought of storing my videos in my server (currently is local but might move it later) and then I did not find a way how to do it so I choose to load it from a YouTube channel I made it for that purpose "I thought It'd look more porf." any way!!!

So far I run my app. in my phone coz I read that Emulator is not capable of running videos. It runs in my phone but with some issues.

1- I have to pause the video ASA the video layout pops up and wait for the video to buffer or something like that otherwise I got error msg "this video can't be played"

2- later when it loads it starts by it self even I did not press the start button. 3- the video is taking the top half of the screen leaving the bottom have a in White space with gap between the two halves.

4- the video is not clear as I can view it in my laptop or in YouTube app.

here is my .java code

public class video extends Activity {


String SrcPath = "rtsp://v8.cache3.c.youtube.com/CjYLENy73wIaLQltaP8vg4qMsBMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYOL6qv2DoMPrUAw=/0/0/0/video.3gp";

/** Called when the activity is first created. */

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video1);
VideoView myVideoView = (VideoView)findViewById(R.id.vview);
myVideoView.setVideoURI(Uri.parse(SrcPath));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
}}

I really want some helps from you ppl.

any help is appreciated dudes.

1 Answers1

0

Well if you want to play video only during a button press. There are two approaches

1) Remove myVideoView.start(); form the code ,i think it will stop playing of video on load

2)Next approach is do not set default MediaControllerfor video view

you can create custom play button for playing video and give myVideoView.start(); inside it's onclick

Button play = (Button) findViewById(R.id.btnPlay);
play .setOnClickListener(this);
Button pause = (Button) findViewById(R.id.btnPause);
pause .setOnClickListener(this);
Button stop = (Button) findViewById(R.id.btnStop);
stop .setOnClickListener(this);
public void onClick(View v) {
switch(v.getId()){
case R.id.btnPlay:
     myVideoView.start();
    /*  the instruccions of the button */
    break;
case R.id.btnPause:
    /*  the instruccions of the button */
    break;
case R.id.btnStop:
      myVideoView.stop();
    /*  the instruccions of the button */
    break;
  }
}

And the thing about clarity of video you are playing rtsp link which got low quality video eve you can see in link itselp you can see .3gp extension which is low quality

If you want to improve the quality . Have an eye on this YouTube api

REFER

Community
  • 1
  • 1
edwin
  • 7,985
  • 10
  • 51
  • 82