Sorry, this video cannot be played - streaming mp4 to android - android

I've searched all over for a solution to this (including SO), however still haven't found a solution.
I need to have a simple video playback in my app. It's a bit less straightforward than a simple window with a video. Simplified, I have two layouts on my screen, one containing some other stuff and the other is to have the video window. There's also a button to switch between the two. This all works just fine, after I figured out that the videoview cannot be present on a view with visibility 'gone' - therefore I'm adding/removing it to/from container layout when needed.
However, I have the problem with the actual video playback. When I try to activate it, I get the dreaded error Sorry, this video cannot be played. One of the questions here on SO is discussing video formats (Android -- Can't play any videos (mp4/mov/3gp/etc.)?) - however I already have what seems to be the correct format, with 320px width and everything else. One of the answers on that thread mentions that videos from here "definitely work". I tried a couple from there - but I got another common beast: Sorry, this video is not valid for streaming to this device.
Please note that I'm testing on an actual device, as video playback is not working in the emulator. Also note that the solution must work on Android 1.6 and above (client's requirement). The device I'm testing on is LG GT540 Optimus with Android 2.1 (at present I don't have any other devices available).
From what I figured out, if I don't use qt-faststart on the videos, I get error Sorry, this video is not valid for streaming to this device. If I do use qt-faststart, then I get Sorry, this video cannot be played.
Here's my code for the playback:
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 is to be progressive-downloaded from HTTP: object.getVideoURL() returns http://www.ooklnet.com/files/381/381489/video.mp4
Can anybody please help me sort this out? This is the last thing I need to complete before the whole app is ready.
Many thanks!
Edit: I tried using MediaPlayer - but got even worse results than with VideoView, so went back to VideoView. Now, in simulator, I get a black screen with controls hovering over it and the sound of the video is playing fine, also the progress is adjusting as the playback continues. However on my actual device, I'm still getting Sorry, this video cannot be played. error

Turned out the problem was with the format of the videos (specifically, the parameters I used with ffmpeg to create the MP4 videos). I ensured that the videos are baseline H.264 - and everything worked properly. See this question for more details.

Maybe you need to change the way you set up your MediaPlayer. I just plugged the url of your sample video into the apidemos example and it worked just fine.
See:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/media/MediaPlayerDemo_Video.html
Hope that helps.

Related

Android Video on Chromebook dropping First Few Frames

I have an app which plays a lot of video files. It's been all good on every phone and tablet I've tested on. I just tested on an Acer Chromebook and the first few frames (maybe up to a 1/4 second) are being dropped on all video files, so the video appears to start just slightly beyond 0. Some of the videos have audio that starts immediately and so it's obvious to the user that the video is clipped at the start. I'm wondering if anyone else has seen this issue, maybe on a Chromebook or other device and if there is some simple way to deal with it?
There is absolutely nothing fancy about my code. I'm using VideoView, preload the video with setVideoURI(), then call videoView.start() on a button press.
Thanks!
This problem only appears if I make a call to seek(0). So rather than doing that to replay the video I have to load the video each time it's requested. That workaround resolves the problem.

Cordova/Crosswalk <video> element only plays once, then black

I have an issue with the latest cca, if I add a <video> to the page and play it it pretty much always works the first time. If I then try to play the video again the view appears to come to the surface but the video never actually plays.
I've found various bug reports and PRs but the issue still prevails.
https://github.com/crosswalk-project/crosswalk/pull/1827/commits/67ad7129c37ff98b049469e673bfa46f3dfdb856
https://crosswalk-project.org/jira/browse/XWALK-7215
I've tried cache busting the video, destroying and recreating the element, stopping and rewinding and then playing the video but nothing seems to work.
The video(s) are all mp4 with an aac audio track, f-frames are disabled and I've tried webm videos as well.
Answering my own question, there was a couple of issues with the particular setup and the video files.
The Cordova app is running on Android, on an ODroid C2.
For some reason the MP4 container doesn't work on this particular setup, WebM works 100% of the time.
Some of the videos were VP9 encoded which didn't work in either MP4 or WebM container.
The fix is to use VP8 encoding in the WebM container.

Play two Videos at same time

I have an app that shows a dancing toy in a VideoView at full screen. Sometimes another video executes over the video of the toy, in this case i have problems with the view because the video of the top shows transparent.
If i set vid1.stopPlayback(); before call the second video, it works, but i cant reproduce the first.
Is there some way to play both videos at same time?
I am not fully certain, but I got a feeling I've read simultaneous video playback may not be possible due to the way it is rendered on the screen. I can't find where I read about this, but you may try searching that way though.

Videos not clear while playing with video view in android

Guys
I am new to android and want to write a simple application that plays a video in android using video view. I have written the code it is working but the view is not clear. It is blurred. What should I do?? Please Help.
Is there any alternative to video view to achieve that...?? I want to play the recorded video from android phones
There are two possibilities. Either the quality of the video might be low or you would have tried it in a emulator. Sometimes it is possible for emulator to have some problems with playing video which I have personally faced. So you have to try it in a real device.
And regarding alternative for videoview, there is no such alternatives available I believe. But still videoview should be simple to play a video.

Playing .MP4 video from raw resource folder

I've seen a number of similar questions, but so far I've not been able to get anything working.
I'm trying to playback a video (.MP4) from the res/raw folder and only get audio, no video. The video is short (about 3 seconds), small (350KB) and if I put the video on the device (Motorola Droid) directly, it plays fine. It also plays fine if I modify the app to read it from the SD card rather than the resource folder. The behavior is the same on both the emulator and the actual device.
Unfortunately, I need this video to be an intro shown just prior to the main screen for my app, so it has to be part of the package. Additionally, one of the app requirements is that the app is available offline, so I can't stream from a web server. I've tried a VideoView, SurfaceView and MediaPlayer, none of them work.
Is it possible to playback video from the resource folder? I've read something about compression possibly screwing the video up, is it possible to manually decompress the video and then play it, and if so, how would that work? This seems like it should be a pretty basic operation, am I just missing something?
I was having the same trouble, tried everything too, agree it should be easier... and documented. Just fixed by passing VideoView.setVideoUri a string with the android.resource protocol, as described here.
The first option doesn't work for me, but the second does:
Uri uri = Uri.parse("android.resource://[package]/"+R.raw.[video_resid]);
Hopefully works for you too.

Categories

Resources