播放视频文件中的android [英] Play Video file in android
问题描述
我放在视频的MP4,以我的域名空间。我有它的公共网址,现在我想发挥它在我的Android应用程序;但不知道我怎么能做到这一点。我用下面的code这是行不通的。轨道器是移动,但我不能在屏幕上看到的任何视频。
I am placed video MP4 to my domain space. I have its public URL, Now i want to play it in my android app; but don't know how can I do this. I used following code which is not working. Track controller is moving but I can't see any video on screen.
public class MPlayer extends Activity{
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.playvideo);
VideoView videoView = new VideoView(MPlayer.this);
videoView.setMediaController(new MediaController(this));
videoView.setVideoURI(Uri.parse("http://www.semanticdevlab.com/abc.mp4"));
videoView.requestFocus();
videoView.start();
LinearLayout l = (LinearLayout)findViewById(R.id.mplayer);
l.addView(videoView);
}
}
帮助我。紧急
推荐答案
在大多数情况下,我使用的是下面的code:
Most of the time, I'm using following code:
MediaPlayer mp = new MediaPlayer();
mp.setDataSource(PATH_TO_FILE);
mp.prepare();
mp.start();
有关详细信息,看看这个页面: http://developer.android。 COM /引导/主题/媒体/ index.html的 和 <一href="http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Video.html" rel="nofollow">http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Video.html
for more information look at this page: http://developer.android.com/guide/topics/media/index.html and http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Video.html
这篇关于播放视频文件中的android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!