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.
Related
I am trying to play my own videos in Android Leanback example (https://github.com/googlesamples/androidtv-Leanback) putting in PlaybackFragment.java line 178, in prepareMediaForPlaying(Uri.parse(...)) my own mp4 url and it doesn't work. I have an Source error and the log said that it couldn't access to this url. I know that the url that I am trying works properly, because I put it in a browser and it plays.
Could you help me please?
Try to understand which type of video are you going to play! HLS, DASH, MPEG or of which format!
after you got a basic understanding on them, look for exoplayer supporting video formats, then implement your desired one
I have been searching all around the web to try to understand how to stream videos to my android app.
I learned:
That the videos must be in the HLS or MPEG-DASH format to be adaptive for streaming .
What I mean by adaptive streaming:
The kind of streaming that allows the user to change the quality while video is streaming.
What could help me do this:
The first thing should be to encode my videos into an HLS or MPEG-DASH, for that I found a service that could do this which is Bitmovin.
The second thing is to play the adaptive video, I found two ways exoplayer and Bitmovin-player.
The problem:
I made an account on bitmovin and tried to test an mp4 video to encode, but there are too many stuff there like input, output and manifest and I don't know what URL I should use to pass to the bitmovin player to play. I encoded the video but I don't know where the reference to the enocoded video is.
My question:
1) Is my approach of streaming videos correct?
2) Can someone explain which url I must pass to the player or where I can find the video that was encoded in Bitmovin cloud?
1) Is my approach of streaming videos correct?
Short answer: Yes :) Adaptive streaming is used by almost every major VoD platform out there, and a proper way to do that. Further it allows you and your viewers to either
let the player decide on its own to select the optimal quality for the given connection and device of the viewer to provide continuous playback
and the viewer can select a specific quality on their own as well, if they want to.
When creating adaptive streaming content using MPEG-DASH and/or HLS as streaming format, your output would typically consist of the following:
Video/Audio Segments
MPD Manifest, and/or HLS playlists
1) Your input file (e.g. an mp4 file) will be downloaded and splitted into segments, which are being processed by the Bitmovin encoding. Out of these, it creates the different qualities the player or your viewer can choose from later.
2) This segmented output is then transferred back to your own storage, e.g. a cloud storage like AWS Simple Storage, or Google Cloud Storage. Other output types like (S)FTP and many others can be used as well.
3) In order to play your created MPEG-DASH or HLS content, a MPD manifest and/or HLS playlist needs to be created. Those are basically an index for the player, which tells it which qualities are available and where to find them to start the playback.
2) Can someone explain which url I must pass to the player or where I can find the video that was encoded in Bitmovin cloud?
The URL you would have to provide to the player, has to point the MPD and/or HLS master playlist, that gets transferred to your storage. Bitmovin doesn't offer a hosting service for your encoded content, which is why you didn't find an URL to the manifest that is used. So you would need a storage first, where the encoding could be transferred to.
Give the getting started guide a try. Select your preferred API client. Then you will be guided step by step on how to integrate this encoding service. I hope this helps :)
To test the playback of the player you can also have a look at https://bitmovin.com/demos/stream-test and select "Use our defaults" which provide URL's to sample content for testing the player and playback.
Now this is a really stupid one! Forgive me on this question please but I really don't know the answer to it. My question is What have Youtube used to play videos intheir Android app? I mean is it a WebView or Just a simple VideoView? I used VideoView to play videos from the URL associated with them but it doesn't look as nice as YouTube's VideoView (or whatever it is)
And is there any other option to play videos from a URL other than using the code below? Because it just plays video in the native video player. If the red-marked portion in the image below is a VideoView, how does it look better than the normal VideoView? Or is it a WebView? Which one is a better option (in terms of UI) to play video from a URL? I'm using GingerBread and want to play mp4 or .flv videos in a VideoView or WebView (whichever is the better option, preferably like Android's YouTube app)
Uri data = Uri.parse(movieurl);
intent.setDataAndType(data,"video/3gpp");
startActivity(intent);
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
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.