Playing videos in android by using videoview from remote url [duplicate] - android

I have managed to stream video from internet using Video View
Uri uri=Uri.parse(videoFileList[0]);
VideoView vv=(VideoView) this.findViewById(R.id.vv);
vv.setVisibility(1);
vv.bringToFront();
vv.setVideoURI(uri);
vv.setMediaController(new MediaController(this));
vv.requestFocus();
But the video page displays as blank at first. Only if I click on the blank space the video view appeares.
Can any body give a solution to display it automatically?

Try this. It worked for me.
void playvideo(String url)
{
String link=url;
Log.e("url",link);
view1 = (VideoView) findViewById(R.id.myVideoView);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mc = new MediaController(this);
mc.setMediaPlayer(view1);
view1.setMediaController(mc);
view1.setVideoURI(Uri.parse(link));
view1.requestFocus();
view1.start();
}

Related

Playing video through URL of Youtube in Android

I want to play video through URL of YouTube Using VideoView in Android. Please help me.
try this :
videoView = (VideoView) findViewById(R.id.video_view);
waitSign = (ProgressBar) findViewById(R.id.progress_bar);
waitSign.setVisibility(View.VISIBLE);
MediaController contorls = new MediaController(this);
contorls.setAnchorView(videoView);
videoView.setMediaController(contorls);
String url = "http://www.somedomain.com/samplevideo.mp4";
videoView.setVideoURI(Uri.parse(url));
videoView.start();
remember to put the extension on the file name

How to play mp4 video in android

I want to play mp4 video from server in android.
Video URL
I tried with using video view but there is blank screen appear.
I also tried with Intent.Action view but it show message "Cant play video".
Is there any other way to do this ?
Thanks in advance.
Use Like this:
Uri uri = Uri.parse(URL); //Declare your url here.
VideoView mVideoView = (VideoView)findViewById(R.id.videoview)
mVideoView.setMediaController(new MediaController(this));
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();
Another Method:
String LINK = "type_here_the_link";
VideoView mVideoView = (VideoView) findViewById(R.id.videoview);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
mVideoView.setMediaController(mc);
mVideoView.setVideoURI(video);
mVideoView.start();

How to play a mp4 videos in Android through Server

I am using following code to play mp4 videos which is stored in sever.... And i am get error like this->
This Video can not be played????
Uri video = Uri.parse("http://129.0.0.....");
MediaController mediaController = null;
mVideoView.setMediaController(mediaController);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://129.0.0....")));
mVideoView.setVideoURI(video);
mVideoView.setVideoPath("http://129.0.0......");
mVideoView.requestFocus();
mVideoView.start();
This might be helpful to you i have used this in android 2.3.3.
public void videoPlayer(String path, String fileName, boolean autoplay){
//get current window information, and set format, set it up differently, if you need some special effects
getWindow().setFormat(PixelFormat.TRANSLUCENT);
//the VideoView will hold the video
VideoView videoHolder = new VideoView(this);
//MediaController is the ui control howering above the video (just like in the default youtube player).
videoHolder.setMediaController(new MediaController(this));
//assing a video file to the video holder
videoHolder.setVideoURI(Uri.parse(YOUR_SERVER_VIDEOFILE_URL));
//get focus, before playing the video.
videoHolder.requestFocus();
if(autoplay){
videoHolder.start();
}
}
Always pass the mp4,3gp etc video format link in URI.Try this code:
VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://hermes.sprc.samsung.pl/widget/tmp/testh.3gp"));
videoView.requestFocus();
videoView.start();

Unable to play Youtube stream via VideoView. How do I fix this?

I'm trying to play a youtube video using VideoView. It gives me "can not play video" error. What am I doing wrong in the code below. The URL I am using is just regular youtube URL : http://www.youtube.com/watch?v=q7u30Li-oOc
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
setContentView(R.layout.main);
//init components for use
mVideoView = (VideoView) findViewById(R.id.video);
text = (TextView)findViewById(R.id.textView1);
//Get URI data from VideoDemo activity
Bundle uristream = getIntent().getExtras();
videoUri = uristream.getString("urivalue");
//set Texfield to URI string
text.setText(videoUri);
//mVideoView.setVideoPath(videoUri);
//provide VideoView component with file path and play
mVideoView.setVideoURI(Uri.parse(videoUri));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();
}
no need to create separate video view we can play youtube videos directly by using this intent
startActivity(newIntent(Intent.ACTION_VIEW,Uri.parse("video url")));
It is because your phone does not support MP4 videos. Try using video players like daroon which play all sort of videos. First test your application if you able to play videos with .3gp extension. If you cannot, then the problem is with your code.
Uri video = Uri.parse(videoUri);
videoView.setMediaController(mediaController);
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(videoUri)));
videoView.setVideoURI(video);
videoView.setVideoPath(videoUri);
videoView.requestFocus();
videoView.start();
For more info, go through android media format support
I ran the same exact code above , but instead of using a youtube url for the videoUri. I uploaded a video to my site database and set videouri to that URL. IT WORKED!! Apparently VideoView and Youtube streams do not work well together.
mVideoView.setVideoURI(Uri.parse(videoUri));
mVideoView.setMediaController(new MediaController(this));
mVideoView.requestFocus();
mVideoView.start();

Android Video Streaming using Video View (video view not showing automatially)

I have managed to stream video from internet using Video View
Uri uri=Uri.parse(videoFileList[0]);
VideoView vv=(VideoView) this.findViewById(R.id.vv);
vv.setVisibility(1);
vv.bringToFront();
vv.setVideoURI(uri);
vv.setMediaController(new MediaController(this));
vv.requestFocus();
But the video page displays as blank at first. Only if I click on the blank space the video view appeares.
Can any body give a solution to display it automatically?
Try this. It worked for me.
void playvideo(String url)
{
String link=url;
Log.e("url",link);
view1 = (VideoView) findViewById(R.id.myVideoView);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
MediaController mc = new MediaController(this);
mc.setMediaPlayer(view1);
view1.setMediaController(mc);
view1.setVideoURI(Uri.parse(link));
view1.requestFocus();
view1.start();
}

Categories

Resources