.mov file will play in browser, but not in native MediaPlayer app - android

I am launching the MediaPlayer to play a .mov file that is being passed into the MediaPlayer as a Uri (which is standard). However, it is telling me that it cannot play the file. However, if I put this same link on the web, and the click the link to launch the movie (while in my Android browser) the video plays no problem. However, I can't get the WebView to play it with the Video tag despite all my efforts.
So here is my question, what magic is taking place that allows an android browser app to take a .html url which contains a link to play a video and play it? If I load the same url in a WebView, or try to pass the video url into the mediaplayer, it is a no go. The format of the video is .mov.
Thanks in advance to everyone.

The Android browser and WebView are very different, WebView is very barebones as it was designed expecting people to use it for very basic showing html webpages. WebView by default has no plugins enabled, no javascript enabled and so on and so on. Never expect that because something works in the browser that it will work in a WebView.
Now in regards to how the media is handled. The Browser has extra features set up to strip the video source from the page and launch it in the native player most of the time. This functionality is not built into WebView. And the native player is very picky about what needs to passed into it as a URI to be able to play it.
Hope that helps,
Stevy888

Related

load movie trailer in android application from imdb

Is it somehow possible, you can load the movie trailers from imdb to videoView or the native android player.
so far, what i've tried.
Iframe approach which let me load trailer in webview, which is exactly i don't want.
Here i found a link which is something a direct link to stream.
I want this to play in video view or native android control.
thanks in advance.
The link you have above is not a direct link to the video - it is actually a link to a web page which contains an embedded player, which in turn has a link to the actual trailer video itself.
You can see the link the to the video if you use the network timeline tab in a browser inspector to look at the network requests. For your example above the client (the browser running the HTML5 page you have downloaded) is requesting the video m3u8 file with the following request:
http://imdb-video.media-imdb.com/vi1225109529/1421100405014-mxwp62-1434643350557.m3u8
This is the 'index' file for a HLS format video file - it tells the client where to request the video streams. The client then downloads the video chunk by chunk which you can see as requests for TS segments - e.g. for you example above:
http://imdb-video.media-imdb.com/vi1225109529/1421100405014-mxwp62-143464335055700002.ts
If the IMDB site does not protect or restrict the video in some way (for example only allowing it play from their embedded web page) then in theory Android should be able to play a HLS file if you point the Media Player towards the m3u8 file. In practice however Android has well know issues with HLS playback so you may find it problematic - see this summary: http://www.jwplayer.com/blog/the-pain-of-live-streaming-on-android/

What does android web browser use for playing audio streams? MediaPlayer or something else?

I have rtsp audio streams from a specific site (m.aveamuzik.com) that play within a browser. When I try to play the same stream using MediaPlayer class, I get MEDIA_ERROR_UNKNOWN (with extra=-2147483648). The error is not well documented but a little googling shows that it is most probably because of unsupported media format.
My question is, if MediaPlayer class does not support some format, how does the built-in browser play it? Also, how to use the same mechanism used by the browser in my code, instead of the MediaPlayer class?
Edit 1: #Joe
I tried the following code:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(streamURL));
startActivity(intent);
MX Player and BSPlayer showed up as options to open the file, but not anything related with AudioPreviewActivity. Actually this is quite reasonable as my URLs are rtsp, but the intent filters for AudioPreviewActivity are just for http, file and content type of URIs.
Fact
The Browser has extra features set up to strip the video source from the page and launch it in the native player most of the time. This functionality is not built into WebView, and the native player is very picky about what needs to passed into it as a URI to be able to play it.
It works since Gingerbread in the default android browser.
Possible explaination
You probably don't use the MediaPlayer the way the android browser does. Post some code to help futher help.
Further help
The MediaPlayer has a lot of bugs before 4.0 (that fixed a lot a RTSP bugs).
The Web Audio API as described by W3C: link
Here is a detailed list of all media formats and protocols supported by Android: link
Testing page: link
This complete blog post also helped me about media streaming for Android: link
If it looked like the screenshot on this other question when it is playing in the Browser, then it should be the AudioPreview Activity from the Music app.
You should be able to
launch it by simply calling startActivity() with an Intent that matched one of its IntentFilter in the manifest.

Embedded video inside of Android media player

I have an application that I want to play a video in. I want to play the video from an embed code via html5 in an iframe. Is it possible to call the androids stock video player to play the video from the iframe embed code?
I fixed this by putting my embed code in an html file inside the assets folder. works greate.

Streaming videos from websites?

I am trying to make an app that allows me to stream a video from a website and play that video in my app.
However, I would like to play this video from my app and not through youtube or anything else.
So you click a button and a video starts streaming and stays in my app and plays. Also, another quick question here, can I play videos from anywhere?
I think I read that it had to be .mp4 or something but im not sure. How can I tell if it's .mp4 by just looking at it?
If I really want to play a video that isnt .mp4 (or whatever it's supposed to be) is there any way at all that I could possibly play it?
The quickest way is to have a view dedicated to a Flash player which streams the video for you. You can generate the HTML at runtime and pass it into a WebView.
This is probably not what you are looking for because you mention that you want it to stream directly with Android. I thought I would put the suggestion out there though.
Edit:
You would use a WebView. Using the following function:
loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl);
You pass in a base URL, which in this case can just be file:///android_asset/ and the data is your complete HTML code. etc.
The data would be set like so:
String data = "<html><head></head><body>flash player goes here</body></html>";
You would set the Flash player to occupy the whole screen, so that the size of the player is then determined by the size of your WebView.

What is most preferred method to play video and audio on mobile website?

What is most preferred method to play video and audio on mobile websites?
I want to know if I'm having and Video and an MP3 file then how to convert them and embed in a webpage which is a page of mobile website.
I think you know the answer to that already since you're tagging this as HTML5!
Use the audio and video elements. Use a fallback to Flash if you so wish.

Categories

Resources