Sorry, this video cannot be played - mp4 streaming on Android

I searched all the solutions for this (including SO), but still haven't found a solution.

I need to have simple video playback in my application. This is a little less simple than a simple video window. Simplified, I have two layouts on my screen, one of which contains some other things, and the other a video window. There is also a button to switch between them. All this works very well after I realized that the video review cannot be present on the view with the visibility β€œgone” - so I add / remove it to / from the container layout when necessary.

However, I have a problem with the actual video playing. When I try to activate it, I get a terrible error Sorry, this video cannot be played. One of the questions here on SO discusses video formats ( Android - can't play videos (mp4 / mov / 3gp / etc.)? ) - however, I already have what seems right, with a width of 320 pixels and everything else. One answer on this topic mentions that the videos from here "definitely work." I tried a couple from there, but I got another ordinary beast: Sorry, this video is not valid for streaming to this device.

Please note that I am testing on the device itself, since video playback does not work in the emulator. Also note that the solution should work on Android 1.6 and higher (client requirement). The device I'm testing on is the LG GT540 Optimus with Android 2.1 (I currently have no other devices available).

From what I understood, if I do not use qt-faststart for the video, I get the error Sorry, this video is not valid for streaming to this device. If I use qt-faststart , then I get Sorry, this video cannot be played.

Here is my code to play:

 VideoViewer videoPlayer = new VideoViewer(this); MediaController mediaController = new MediaController(this); mediaController.setAnchorView(videoPlayer); videoPlayer.setMediaController(mediaController); videoPlayer.setVideoURI(Uri.parse(object.getVideoURL())); LinearLayout container = (LinearLayout)ObjectInfo.this.findViewById(R.id.VideoContainer); container.setVisibility(VISIBLE); container.addView(videoPlayer, new LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.FILL_PARENT)); videoPlayer.requestFocus(); videoPlayer.start(); 

Now the video I'm trying to play should be progressively downloaded from HTTP: object.getVideoURL() returns http://www.ooklnet.com/files/381/381489/video.mp4

Can someone please help me deal with this? This is the last thing I need to complete before the entire application is ready.

Many thanks!

Edit: I tried using MediaPlayer - but got even worse results than with VideoView, so I returned to VideoView. Now, in the simulator, I get a black screen with controls hovering above it, and the sound of the video plays normally, and progress is adjusted as playback continues. However, on my device itself, I still get Sorry, this video cannot be played. a mistake

+8
android video
source share
2 answers

It turned out that the problem is related to the video format (in particular, to the parameters that I used with ffmpeg to create MP4 videos). I guaranteed that baseline H.264 videos - and everything works correctly. See this question for more details.

+6
source share

You may need to change the way MediaPlayer is configured. I just plugged the URL of your sample video into the apidemos example and it worked fine.

See: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Video.html

Hope this helps.

+1
source share

All Articles