问题
I've been researching for some time now, and all the questions I can find point to mp4 'hinting' but I have no control over the videos.
I was about to give up when i discovered that MX video player on the android market can somehow play these mp4 urls I have. So at the moment I use an intent to launch the urls in mx player but I'd much rather display the video within my app.
Any ideas how mx player does this would be great,
Thanks
回答1:
Refer this link i had pasted the whole code for playing the mp4 videos in your app by creating a videoview and you might minor error you can manually remove that error.
回答2:
Check this. It will help you.
String LINK = "http://www.boisestatefootball.com/sites/default/files/videos/original/01%20-%20coach%20pete%20bio_4.mp4";
setContentView(R.layout.video);
VideoView videoView =(VideoView)findViewById(R.id.webView);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.requestFocus();
videoView.start();
回答3:
You can do it using FullscreenVideoView
class. Its a small library project. it's gradle is :
compile 'com.github.rtoshiro.fullscreenvideoview:fullscreenvideoview:1.1.0'
It's steps is here:
your VideoView
xml is like this
<com.github.rtoshiro.view.video.FullscreenVideoLayout
android:id="@+id/videoview"
android:layout_width="match_parent"
android:layout_height="match_parent" />
In your activity , initialize it using this way:
FullscreenVideoLayout videoLayout;
videoLayout = (FullscreenVideoLayout) findViewById(R.id.videoview);
videoLayout.setActivity(this);
Uri videoUri = Uri.parse("YOUR_VIDEO_URL");
try {
videoLayout.setVideoURI(videoUri);
} catch (IOException e) {
e.printStackTrace();
}
That's it. Happy coding :)
If want to know more then visit here
来源:https://stackoverflow.com/questions/10870660/play-mp4-file-from-url-on-android