2017-03-06 285 views
1

找到Jiecao视频播放器,这里是link,可以使用在线URL播放视频。从SD卡播放视频的视频播放器

JCFullScreenActivity.toActivity(this, 
    "http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4", 
    JCVideoPlayerStandard.class, 
    "Title"); 

但是,如果我有打从SD卡中的视频,如:(在下载文件夹中)toystory.mp4

回答

1

首先添加

<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> 

AndroidManifest

和 使用此

String fileName = "YourVideo.mp4"; //your file name in downloads folder 
     String completePath = Environment.getExternalStorageDirectory() + "/Download/" + fileName; //your file path 

     //File file = new File(completePath); 
     //Uri video = Uri.fromFile(file); 
JCFullScreenActivity.toActivity(this, 
    completePath, 
    JCVideoPlayerStandard.class, 
    "Title"); 

我分析github上的代码,发现它只是用MediaPlayer 并通过URI到它的。

+0

在我的程序中,我只使用了一个单独的活动(即MainActivity)并在全屏幕中默认播放视频,就像您在我的代码中看到的一样......但后退无法退出我的活动......为什么?仍然只是退出全屏模式不关闭活动... – Sophie

+0

你可以发布你的日志? –

+0

请检查此:http://pastebin.com/zJ7Eb4ZK这里是代码:http://pastebin.com/Kz9yRmaN – Sophie