I'm developing an application in which I need to play YouTube videos, I tried using webView and videoView, and I searched around a lot, I actually found some solutions, but they seem not to fit into my application needs:
So I want to know in the first place, the best way (approach) to the issue of playing a YouTube video inside an app. Should I use WebView and try to make the video fit the view and extra, or should I try VideoView (which is a little bit more complicated I guess, cause to be able to play videos I have to get the actual .3gp from Youtube).
Well thanks for helping me find the best approach.
MeanWhile I have got another question: is there a way to make the webView take the whole screen (full screen) on landscape mode (when the phone becomes landscape)?
Using the WebView approach can cause problems on some devices. The VideoView approach will work well as long as you have a solid way to parse the correct url. In one of my applications we do this using regex and parsing through the html, so far it works fast and efficiently.
Related
I'm trying to make an Android App and I need help.
Do you have any idea how to play a online video (like a video on Youtube) in side-by-side view at the very same time by using Android WebView?
so, when I watch a Youtube video, I want to be able to have two views on left and right side on My Android SmartPhone Screen, and play and control the same video both on left and right views at the very same time.
Regards.
----2nd Feb, edited----
following things I've tried and failed.
・using Youtube API, get 3gp address, and try to play it with VideoView
・Using draw method and getDrawingCache method of WebView
・using onShowCustomView of WebView
Look at using a html5 video player like Video.js or Sublime Video. You will need to create some javascript with each of these that fires the left and right video at the same time.
You can also look at what this guys did for some more inspiration.
http://html5demos.com/two-videos
The trick is getting the videos to fire at the same time if you need them in sync. It's not easy to achieve if you don't control the source video and server as you are relying on an outside party to do this. YouTube is NOT a good choice for serving your videos if you need them to be in sync as you can't guarantee the video load and launch times, or control if an ad will get injected into the video stream.
I have googled and googled on this. I cannot seem to find a way of seamlessly playing video in high quality from youtube.
I have tried so far:
Using a webview with the following:
htmlstring.append("<iframe title='YouTube video player' class='youtube-player' type='text/html' width='590px' height='370px' src='http://www.youtube.com/embed/");
htmlstring.append(wYouTubeId+"?autoplay='1' frameborder='0' allowFullScreen='1'></iframe>");
htmlstring.append("</center></body></html>");
webView.loadData(htmlstring.toString(), "text/html", "utf-8");
This has been working fine, but not on android 4 for some reason (Note & S3 tested)
So i tried this object version:
htmlstring.append("<object width='480' height='330'><param name='movie' value='http://www.youtube.com/v/"+wYouTubeId+"?version=3&hl=pt_BR&rel=0'>");
htmlstring.append("</param><param name='allowFullScreen' value='true'></param>");
htmlstring.append("<param name='allowscriptaccess' value='always'></param>");
htmlstring.append("<embed src='http://www.youtube.com/v/"+wYouTubeId+"?version=3&hl=pt_BR&rel=0' ");
htmlstring.append("type='application/x-shockwave-flash' width='480' height='330' allowscriptaccess='always' allowfullscreen='true' /></object>");
webView.loadData(htmlstring.toString(), "text/html", "utf-8");
No joy there either. It just spins and then gives out a blue lego block. These methods work on Android 2.2 though.
Then i tried this:
mp.setDataSource("http://www.youtube.com/v/"+wYouTubeId);
mp.prepare();
mp.start();
I have also tried this with a direct rtsp link found in the channel feed but they are of way too low quality to be usable. How can i tell which version is the high quality one as I am seeing loads of them.
I have also tried doing it manually with a VideoView but i get the same problem.
Lots of people recommend using this:
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(fileListItem.getLink())));
But that is not an option, unless there is a way to launch the youtube app in landscape seamlessly without text. (Our client does not want it).
It seems to me strange that Android is a google system, Youtube is a google system yet on iOS (even iOS6!) it seems that it was easy to implement the video.
Why is it so hard to play a "google" video on "google" android??
This will be the best approach when it's publicly released: https://developers.google.com/events/io/sessions/gooio2012/120/ (I can't share any specific dates regarding its availability).
In the meantime, using the embed will probably get you closest to what you want. What specifically was broken about it when you tried it? Could you file a bug with a description of the problem, including the video ids you tried to play back?
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.
I just want to know if I can see several videos at once from the network using rtsp? I'm trying to do an android app similar to video surveillance and I need to see several videos at the some time in the screen, I tried to use it with MediaPlayer and after that with VideoView, but in the both cases sometimes the videos appear, sometimes give me an error that can not play one or more videos...What can I do to put it to work well?
What Cruceo said is correct. It's better to mux (FFmpeg is really great) all streams in one stream with a incredible resolution with a low bitrate & framerate. Then create a program to display it and make zoom in when you select a viewpoint.
A other option would be to change the video streams into jpg files. This way is allot easier because you can use your web browser to display it. With your web browser you can make use of JavaScript (ProcessingJS is very easy and good at this) to make a image viewer with allot of functionality.
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.