Play Video by staying in the same Activity - android

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.

Related

How to launch Youtube when clicking on an embedded video in my Android WebView

I have a webview which displays some HTML, and includes embedded YouTube videos. The videos are wrapped in an iframe tag and I have setJavascriptEnabled(true) in my Java file, so the video can play in the WebView. However, I would like to be able to launch Youtube when the user clicks the video.
Other posts on SO suggested that I parse out the video ID's and start an intent. However, this seems pretty tedious considering there can be multiple videos. In addition, I'm not sure how to set the iframe to clickable to listen for a click event.
Any suggestions?

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.

VideoView or WebView in YouTube Android App

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);

Youtube video in VideoView

I want to play a remote video in a Videoview. Anybody knows a good free server to load my videos in it to later stream in a videoview? Is possible to see in a videoview Youtube videos? I have see another questions but I donĀ“t understand. Anybody can put a example to play a Youtube video or remote video for another server in a videoview?
Thank you
You can check android-youtube-player, a project to make YouTube videos play in a VideoView. The usage instructions and sample Activity code is available.
You can definitely stream video directly into a VideoView without a problem, and you set it up normally as well:
Uri pathtoVideo = Uri.parse(path);
videoView.setVideoURI(pathToVideo);
However, there are a lot of videos on Youtube that aren't mobile-friendly, and will end up throwing a "This Video Cannot Be Played" error.
The MediaPlayer on Android can only play "progressive streamable contents" which basically means: 1. the movie atom has to precede all the media data atoms. 2. The clip has to be reasonably interleaved. If it doesn't, you'll get the error I mentioned above.
Have you considered the YouTube API for android? I recently posted a tutorial on how to use the video and thumbnail views from the API here

How to create a Video Player

I'm trying to create a simple video player with 3 buttons: play, stop and pause. My video will be from the raw folder or at a server url that I will upload it to. Do you have any tutorial on this in order to get some ideas? Also, I have created a media player with a song, but I think that this can't work for videos, right?
There's a project sample in the SDK for the VideoView. You can attach a MediaController to it, which will show you play/pause stop and skip buttons. It's also on the developer website, here.
this may be what you are looking for: http://davanum.wordpress.com/2009/12/04/android-%E2%80%93-videomusic-player-sample-take-2/
To make this more abstract, the VideoView Widget is what you need.

Categories

Resources