如何使用java android jdk播放外部视频?
Here's an example on how to play video,
but it embeds the video as resource of the apk,
how to play an external video ,e.g. the test.mp4
under the /download
directory of sdcard?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您可以使用视频视图属性来设置外部视频
您可以参考以下链接
http ://r00tsecurity.org/forums/topic/12059-android-videoview-example/
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/VideoViewDemo.html
You can use Video View Property to set an external Video
You can refer the below links
http://r00tsecurity.org/forums/topic/12059-android-videoview-example/
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/VideoViewDemo.html
在此路径中,您还可以设置您的路径,例如
In this path, you can also set your path, e.g.
希望这会起作用。
检查并回复。
Hope this will work.
Check and reply.
要从 Android 中的 SD 卡打开文件,您可以使用
android.os.Environment
中定义的getExternalStorageDirectory()
方法。请务必首先检查系统上是否有可用的 SD 卡。您可以使用从 getExternalStorageDir 方法返回的 File 对象(它是一个目录)来获取实际文件,并且从该新文件对象(实际文件)中,您可以使用实际文件的 uri 调用 MediaPlayer.create 。考虑:文件目录 = Environment.getExternalStorageDir();
File file = File(dir, "filename.mp4");
MediaPlayer 播放器 = MediaPlayer.create(context, file.toURI();
To open a file from say, the sdcard in android you use the
getExternalStorageDirectory()
method that is defined inandroid.os.Environment
. Be sure to also check that an sdcard is available on the system first. You use the File object (it is a directory) returned from the getExternalStorageDir method to get the actual file and from that new file object (the actual file) you can call MediaPlayer.create with the uri of the actual file. Consider:File dir = Environment.getExternalStorageDir();
File file = File(dir, "filename.mp4");
MediaPlayer player = MediaPlayer.create(context, file.toURI();