play youtube video in full screen mode in my android app - android

I am using the following code to play youtube videos in my app.
startActivity(new Intent(Intent.ACTION_VIEW,
Uri.parse("http://www.youtube.com/watch?v=videoid")));
I would like the youtube videos to open in full screen mode. Is there any way to achieve this?

Found this solution today:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com/watch?v=VIDEOID"));
intent.putExtra("force_fullscreen",true);
startActivity(intent);

Try using
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://" + video_id);
startActivity(intent);
The reason is the different Uri. The one you are currently using is just supplying content via http: that happens to be video and get's resolved to youtube. The one with "vnd.youtube" is actually telling the system that you have video content you would like one of the native apps to take care of.
Ahh, if you want to actually play full screen video without using the youtube app (which you can not control) you don't you try to just make your own VideoView?
Check out this link
playback video full screen

Although I failed at this initially, I eventually succeeded by following the instructions at this linkc
http://keyeslabs.com/joomla/projects/youtube-player/244-open-youtube-activity-project-launched-by-keyes-labs
Here you create your own video player and the video gets played in it

Related

How to make it so it asks you what video player you'd like to use when trying to play a video in a Web View?

I'm trying to make it so when you try to play a video in a web view it asks you what video player you'd like to use. Such as MX Player, or the default video player in android. I'm trying to do that so you don't have to play it inside the web view. If you could help me that'd be great!
You don't have to do anything, android handles this. Android finds all relevant video player applications and shows a choice dialog to user.
You can try with this code(put a movieUrl, maybe it is stored in your sd card):
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(movieUrl));
startActivity(intent);
What I did was just make it play the video inside the web view. Thanks a lot though guys.

How to get direct link to video?

I have a problem with playing video in my app. Basically what I want to do is getting direct link to video like: www.embed.videotube.com/player/?id=431436[...].mp4 from: http://embed.videotube.com/player/?id=431436. I've seen some websites like www.videotools.12pings.net which will get proper link.
Is there any option how to cope in situation where there is no proper API ? (example: api for youtube)
After clicking on video thumb:
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("www.embed.videotube.com/player/?id=431436[...].mp4"));
myContext.startActivity(intent);
That seems to be a direct link. You could verify it by running fiddler or any HTTP traffic monitoring tool, while playing the video, the video link will be displayed in the inspector window.

Play Video by staying in the same Activity

I have referred the answers of
android-youtube-app-play-video-intent
how-to-play-youtube-video-in-my-android-application
and many more.All those are playing videos by using Intent which creates a new Window and to be more precise by creating a new Activity.
But,I am having a scenario in which I want to play a Video on click of a Button by staying in the same Activity
refer this video tutorial:
http://mfarhan133.wordpress.com/2010/10/13/using-audio-video-files-tutorial-for-android/
Use a VideoView
http://developer.android.com/reference/android/widget/VideoView.html
If you want to play a video file from phone storage or streaming, you can use VideoView.
If you want to open youtube video, you can use a WebView in your activity and open the youtube link.
See this WebView Tutorial.

Why isn't this triggering the default video player?

I'm using the following code in an application of mine, and it's always used to work with the default video player in Android 3.0 - 3.2. I haven't updated the OS, but for some reason the default video player no longer shows up as an option when you select which application you want to open the video file with.
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.parse(filePath), "video/*");
startActivity(intent);
I may have changed the setDataAndType() method from Uri.fromFile(file) to Uri.parse(filepath), but would that be enough to make such a difference?
Any ideas?
Try using a real MIME type, for the actual type of the video, rather than one with a wildcard.
I've finally found a solution to my question, and I think it's rather weird. The following bit of code does not work:
myIntent.setDataAndType(Uri.parse(filePath), "video/*");
... but this does:
myIntent.setDataAndType(Uri.fromFile(new File(filePath)), "video/*");
It would appear that Uri.fromFile() is required if you want the default OS video player to pop up in the list of applications capable of opening the video file. I have no idea why that's the case though.

Embedding a youtube video into android app using eclipse?

I'm trying to figure out how to embed youtube videos into android using eclipse. I would prefer to use the chromeless player, but at this point it's not necessary.
Any help on how to do this would be greatly appreciated.
The easiest way to embed a Youtube video is to use an intent to fire the Youtube application, like this:
String video_path = "http://www.youtube.com/watch?v=opZ69P-0Jbc";
Uri uri = Uri.parse(video_path);
// With this line the Youtube application, if installed, will launch immediately.
// Without it you will be prompted with a list of the application to choose.
uri = Uri.parse("vnd.youtube:" + uri.getQueryParameter("v"));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
YouTube API for Android is availible now. Following this link, you will find a sample how to use YouTube API under Android.
Using YouTubePlayerView you can play video from youtube in your activity. But it is not possible to change default controls.
If you want to play the video from inside the application to really embed it you can use WebView and load it with just iframe of that youtube video.
WebView webview;
webview.getSettings().setJavaScriptEnabled(true);
webview.loadData("<iframe src=\"http://www.youtube.com/watch?v=hZ4sDn89P04\"></iframe>","text/html","utf-8");

Categories

Resources