how to fetch correct URL to video - android

im trying to play a video in VideoView on an android application.
the question is how do i fetch the correct link to the video from youtube and not just the webpage?
setContentView(R.layout.videopopup);
VideoView vv = (VideoView)findViewById(R.id.videoElem);
MediaController mc = new MediaController(this);
mc.setEnabled(true);
mc.show(0);
vv.setMediaController(mc);
vv.setVideoURI(Uri.parse("http://www.youtube.com/v/oFL2rszPmmU?version=3&feature=player_detailpage"));
vv.requestFocus();
vv.showContextMenu();
vv.start();
in this link: Video View not playing youtube video
Evgeny Nacu explains which link it should be, but not how to retrieve it from a given youtube page.

Simple way to play video using default youtube app:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(your youtube url);
Youtube app will do everything. You need not do anything.
and if that doesn't solve, use webview instead of videoview in your code

Related

Video auto play I want when user click on play button the video play

Video auto play I want when user click on play button the video play.
VideoView videoView =(VideoView)findViewById(R.id.video_view);
MediaController mediaController= new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri=Uri.parse(selectedItem.getTrailerLink());
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
That's pretty simple: don't call start() right away.
Move that to the onClick method for the button, and you're good to go

Android code to play youtube url repeatedly on button click

I am trying to play youtube url play n no of times on button click
I stumbled on the following code on the net:
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://www.youtube.com/watch?v=Ux_kvgL570A"));
startActivity(browserIntent);
but this code plays youtube url only once,how to modify this code if i want to
play youtube url multiple times
Currently, you're using a browser to display the video, but for it, you need use the Youtube API.
This thread: Youtube data API : Get access to media stream and play (JAVA) can explain you a little more about the youtube implementation on android using a media player.
But to repeat a video, you can add the follow lines:
videoView.setOnPreparedListener(new OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
}
});
And this is the reference for the YouTube API: https://developers.google.com/youtube/android/player/sample-applications

How to play video using software like on MX player?

I have troubled in playing a video that is not supported by hardware I want to create a simple video player that can play any video even it is not supported by hardware. I like the way how mx player did it. Can any one help me how to play a video like in MX player. I have this basic syntax but it only plays hardware supported videos. Here's my code
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
Uri uri = uri = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.videointro);
videoView.setMediaController(mediaController);
videoView.setVideoURI(uri);
videoView.requestFocus();
videoView.start();
You need to write intent and for that please pass the video url. Then android will identify apps which will able to play video then you need to pick/select one.

Recording video with mediaplayer

Creating an app. I want to have the app play video from my sdcard, without having to change the code every time. I want to be able to choose from any video on my phone, is this possible and if it is would you mind sharing code.
this is what i have
setContentView(R.layout.activity_play);
VideoView videoView=(VideoView)findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
//Uri video = Uri.parse(Environment.getExternalStorageDirectory().getAbsolutePath()+"filename");
Uri video =Uri.parse("sdcard/KVID0023.mp4");
videoView.setVideoURI(video);
videoView.setMediaController(mediaController);
videoView.start();

disabling video controls in ACTION_VIEW

Hi My Question is want to disable or not to show the video controls if i use ACTION_VIEW for any videos. Do i need to specify any extras for Intent or is there any proper way to achieve this
below is the code for reference
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(appnamesArray[arg2]));
Any Sample links or code helps me a lot
Thanks in Advance
EDIT:
As i understood that action_view starts the default player or user selected player so the controls goes to player and intent has no control to hide it for that i used videoview to show the video from url
VideoView videoView = (VideoView) new VideoView(getApplicationContext());
MediaController mediaController = new MediaController(MainActivity.this);
mediaController.setAnchorView(videoView);
Uri video = Uri.parse(appnamesArray[arg2]);
videoView.setMediaController(null);
videoView.setVideoURI(video);
videoView.start();
setContentView(videoView);
please update me if any one can able to succeed this by doing the ACTION_VIEW itself
If you use the view intent it will have option to open video in all the players that support it. So even if some of the players support hiding controls other might not.
Best solution is to have your own video view.

Categories

Resources