I have a link in the form
http://something.com/some/play.php
When I simply put and go on the browser, the video gets played. It is a live video.
I want to make request to this URL and then run the video in android view.
How to achieve that?
With a VideoView, you should be able to do the following:
String path="http://something.com/some/play.php";
Uri uri=Uri.parse(path);
VideoView video=(VideoView)findViewById(R.id.VideoView01);
video.setVideoURI(uri);
video.start();
Check out the documentation regarding VideoView, and here's an example on how you can stream using VideoView.
Related
I use videoview to play some .gif but cant. when I use to play gif or mp4 I receive cant play video but when I try to use webview everything is ok.
VideoView i = (VideoView) findViewById(R.id.videoView1);
i.setVideoPath("file:///android_asset/ad.gif");
i.start();
The current easiest way to get gifs to work outside of WebView is to use the Glide library with ImageView.
ImageView imageView = (ImageView) findViewById(R.id.my_image_view);
GlideApp.with(context).load("gif_source").into(imageView);
Edit: Didn't realise you also asked about MP4 (early morning). Here's a post which gives some good info on it as it can be quite complicated (things like making sure the MP4 is encoded in a format Android supports).
Hello i have problem i want to play video stream from url link but i have some issue after i use complete url link or without blank space exoplayer player library can detected but after i use file url link blank space cannot detected
example
http://www.something.com/folder/hmmm.mp4 //worked success
after i use this
http://www.something.com/folder/hmmm iknow this blank space.mp4// cannot worked
can someone helpme please thanks
I am gonna answer using the code I used to play video at a URL in exoplayer--
String videoURL="https://d17h27t6h515a5.cloudfront.net/topher/2017/April/58ffdcc8_5-mix-wet-and-cry-batter-together-brownies/5-mix-wet-and-cry-batter-together-brownies.mp4" ;
MediaSource mediaSource = ExtractorMediaSource.Factory(new DefaultHttpDataSourceFactory("exoplayer-codelab"))
.createMediaSource(Uri.parse(videoURL));
So you'll have to give the entire address of video along with video type extension to run successfully.
I have problem to displaying the youtube video with embed code into webview. I am gettinng the html content from webservice with imagess and some text content. Having also youtube embed video code in it. I have successfully display with image and text in it but when youtube embed code comes it will show error like "webpage not available".
So any one having solved this issue before then reply here.
WebView wvDesc = (WebView) findViewById(R.id.wvDesc);
wvDesc.getSettings().setJavaScriptEnabled(true);
wvDesc.getSettings().setPluginState(WebSettings.PluginState.ON);
final String mimeType = "text/html";
final String encoding = "UTF-8";
wvDesc.loadDataWithBaseURL(null, strContent, mimeType, encoding, null);
// where strContent is string which is html content need to display the text and youtube video
am not sure if this is what you need. Anyway I hope the following be useful. You can use the iframe method that youtube provides to play its videos. If the browser supports html5 will show the video with it, otherwise with flash.
You can use the following code as an example
in the above example the video id is bIPcobKMB94. You can change this id and show your video.
You can access a live example of it here
More infromation for youtube iframe
YouTube HTML5 Video Player
In my android app, i want to stream video from URL. For that i am using VideoView control. But it displays starts playing video after loading whole video. I want to perform async video streaming for that. Is async streaming possible with VideoView ? I want to display ProgressBar until video is loaded. Please help me to solve this problem.
Thank you.
Here is my code :
video_view_ = (VideoView) findViewById(R.id.video_view);
video_view_.setVideoURI(Uri.parse(path));
video_view_.setMediaController(new MediaController(this));
video_view_.requestFocus();
video_view_.start();
Somewhere in my Android app I would like to play a youtube video,
in my activity, in a small view.
I'm trying to do this using VideoView, but no luck so far..
I wrote a simple activity, here is my code so far:
public class MainView extends Activity {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
/*working good but IT'S NOT youtube*/ //Uri video = Uri.parse("http://commonsware.com/misc/test2.3gp");
/*NOT WORKING*/ //Uri video = Uri.parse("http://www.youtube.com/watch?v=hLQl3WQQoQ0&ob=av2e");
/*NOT WORKING (RTSP)*/ //Uri video = U-ri.parse("http://m.youtube.com/watch?gl=IL&hl=en&client=mv-google&feature=grec_mobile&v=6WHRxXY67UA");
/*NOT WORKING (RTSP)*/Uri video = Uri.parse("http://m.youtube.com/watch?gl=IL&hl=en&client=mv-google&v=wWub_aXPCVg");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
}
}
is it possible?
is there any other SDK component that can do that?
any ideas?
Thanks,
Amitos80
Google are releasing android components for YouTube "in the coming months", so hopefully by the end of 2012.
What I am doing in the meantime is using a WebView with loadData(), and passing in an IFrame as stated on the YoUTube API page. The Iframe is quite limited (most parameters don't even work, like controls=0), so if you need more flexibility like controlling the view then use the JavaScript API and then embed the JavaScript in the HTMl you pass into loadData.
I tried the Media Controller and couldn't get it to work, even though YouTube use it in there own app.
The other thing to try which i didn't get around to. Is to use the google search apis. You can specify a YouTube video and it will give you the URL's to the thumbnails, videos etc. This way you can get to the raw files (www.youtube.com/...../..../myfile.3gp) rather than calling a webpage. These might then be loadable in the MediaController.
If you know what video you want to view, you could just create an Intent with the url in it and use that to launch the Youtube app. You can see this SO Post for more details.
you can simply use youtube rtsp link in videoview as:
String myurl="rtsp://v4.cache4.c.youtube.com/CjYLENy73wIaLQk_ezfHQ9mvqRMYDSANFEIJbXYtZ29vZ2xlSARSBXdhdGNoYN-__7O28NSPUAw=/0/0/0/video.3gp";
Uri video = Uri.parse(myurl);
mVideoView = new VideoView(this);
mVideoView.setVideoURI(video);
myMediaController = new MediaController(this);
it works simply for me.