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

穿精又带淫゛_ 提交于 2019-11-27 07:27:10

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.

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.

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!!!

I kept getting the same "Can't Play Video" message while trying to play video from the phone itself. First I didn't input good path to a file but there was anther interesting issue.

  1. I've type path from the root, example /videoFileName.mp4 and I should have type it with sdcard in between like /sdcard/videoFileName.mp4

  2. My Sony Ercisson Xperia Arc was connected as a usb mass device storage at the same time I was running my app through adb, so internal sd card was unmounted and file could not be found. I've discovered this when I tryed same code on Samsung Galaxy S which behaves differently when connected.

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

  1. I could stream videos from Dropbox/AWS
  2. Stream videos from youtube.

Things still depend upon codecs supported by the device.

If you have mp4 file having H.264 baseline encoding and still you are unable to play video in your android device then it might be problem in .htAccess file on server side. It might be zipping .mp4 file. few devices are able to play video by unzipping it and stream it but not in all device cases. You need to change .htAccess file on server side. Change in output filter and include file format .mp4 to exclude it from being zip at streaming time.

SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|swf|mp4)$ \ no-gzip dont-vary

I had this same issue while using VideoView, while i tried to check all things regarding the video the issue was in the AndroidManifest.xml File, It was regarding the permission to use EXTERNAL STORAGE give it a shot it might solve the issue.

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

I faced the same issue once. In My case only issue was fie format. i Just changed the video format to .mp4 and it works like charm on all the devices and emulator i used. my suggestion is to check your video format first and then try other solutions.

For me was a problem with the codec used by video. I installed the Any Video Converter and converted the video using the settings for Google Android (x264). Now I can play on every device.

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!