Strange Behavior of Android VideoView - “Can't Play Video”

前端 未结 11 1344
無奈伤痛
無奈伤痛 2020-11-30 03:06

In my application,showing video from sdcard folder or new taken video from Video intent in a VideoView in different Activity by passing file path of the video selected.

相关标签:
11条回答
  • 2020-11-30 03:41

    I came across the same problem and what worked for is adding the Internet permission to the manifest file since I am getting video from url.

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

    This is how I am populating listview of videos.

       //assign video
        mVideosListView = (ListView) findViewById(R.id.videoListView);
    
        //create videos
        Video riverVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862009639.mp4");
        Video carsVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862013714.mp4");
        Video townVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014159.mp4");
        Video whiteCarVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014159.mp4");
        Video parkVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862014834.mp4");
        Video busyCityVideo = new Video("https://s3.amazonaws.com/androidvideostutorial/862017385.mp4");
    
        mVideosList.add(riverVideo);
        mVideosList.add(carsVideo);
        mVideosList.add(townVideo);
        mVideosList.add(whiteCarVideo);
        mVideosList.add(parkVideo);
        mVideosList.add(busyCityVideo);
    
        /***populate video list to adapter**/
        mVideoAdapter = new VideoAdapter(this, mVideosList);
        mVideosListView.setAdapter(mVideoAdapter);
    

    0 讨论(0)
  • 2020-11-30 03:42

    1)When the message "Can't Play Video" occurs?

    Android usually gives out this message, when it is not able to play the media content. The reasons for this to happen can be anything like

    • Unsupported file format
    • Unsupported codecs
    • Erroneous content

    to mention a few.

    2)What are the Solution for that?

    Unless you have your own Media Framework in your app, there is no solution from the application level

    3) What could be possible mistakes in my application?

    Very unlikely the mistake is in your application. If you read the logs, you will see that the error seems to originate from the DataSource of opencore (Which version of android are you running anyway? It is still using Opencore instead of StageFright). It is recognizing it as a large file (> 2GB) and hence giving out the error "E/OsclDirectFileIO( 2182): [LargeFileSupport] OsclDirectFileIO::OpenFileOrSharedFd Error = -1"

    The other thing to note is certain phones have better multimedia capability than the other phones, since OEM's can themselves improve the multimedia capability. So there is no written guarantee that all files can be played on all devices, even though it conforms to the supported formats, codecs mentioned by Android.

    0 讨论(0)
  • 2020-11-30 03:43

    Make sure that your video is in MP4 format , but if still does not play or shows same error then fault is not with the code. Fault is in the video resolution. just check height and width of you video and match it with you video view component. There are lot of free video compressors Online available. So just compress your video and test it.

    It will work. Cheers!!!

    0 讨论(0)
  • 2020-11-30 03:44

    Google recently open-sourced Exoplayer after Google IO 2014. My experience with video playing with it was good so far.

    https://github.com/google/ExoPlayer

    • I could stream videos from Dropbox/AWS
    • Stream videos from youtube.

    Things still depend upon codecs supported by the device.

    0 讨论(0)
  • 2020-11-30 03:45

    My problem was I had saved it in .avi format instead of .m4v format, and it worked liked a charm on my Samsung...thanks for everyone's help!

    0 讨论(0)
  • 2020-11-30 03:48

    Its all about format problem, Some phone record the video in mp4 format and some in 3gp format, but in almost all phones the default mediaplayer support 3gp format. So the solution is you need to convert it into 3gp at the time of playing. This thing is difficult to handle in android, So at server end you can do it easily and hence whatever the format of the video is being uploaded you can download it in one format .3gp and it will work fine.

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