Search code examples
androidandroid-video-player

Video Player to play Video from SD Card


Found Jiecao Video Player, here is the link of that one and able to play video using online URL.

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

But, What If I have to play a Video from SD Card, like: toystory.mp4 (available in Download folder)


Solution

  • First add

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

    to your AndroidManifest

    and use this

    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");
    

    I analysed github code and found that it's just using MediaPlayer and passing uri to it.