2017-03-06 290 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