How to play videos from SD Card

前端 未结 5 1896
日久生厌
日久生厌 2020-12-17 16:51

I was creating a simple app which stream videos from net and I made it but now I want to change the code so that I can play video files from my SDCard

original code:

相关标签:
5条回答
  • 2020-12-17 17:04

    The videoView.setVideoURI(vidFile); method needs to be replaced by the videoView.setVideoPath(path); method. Here path specifies the path of the video file on the SDCARD.

    This path can be easily retrieved using the MediaStore.Video.Media.DATA property of that video file or by just entering the songpath statically as /sdcard/songname.

    0 讨论(0)
  • 2020-12-17 17:10
    Uri vidFile = Uri.parse(
       Environment.getExternalStorageDirectory().getAbsolutePath()+"filename");
    ... 
    

    the rest of the code will be same.

    0 讨论(0)
  • 2020-12-17 17:12

    In place of

    videoView.setVideoUri(vidFile)

    use

    videoView.setVideoPath("/sdcard/SONG.").

    Let me know.

    0 讨论(0)
  • 2020-12-17 17:12

    I also tried your code and got same error message but when I tried with video path with no blank space in path or name, it worked well. Just give it a try. e.g, file path "/mnt/sdcard/Movies/Long Drive Song - Khiladi 786 ft. Akshay Kumar_Asin-YouTube.mp4" gave the error but file path "/mnt/sdcard/Movies/Khiladi.mp4" worked well.

    0 讨论(0)
  • 2020-12-17 17:21

    these links may help you:

    Playing 3gp video in SD card of Android

    how-play-video-and-audio-android

    Using VideoView to play mp4 from sdcard

    0 讨论(0)
提交回复
热议问题