Cannot play video, android - android

I have used an mp4 video with a 400x760 resolution at 30fps and integrated it into an app using VideoView and MediaController
MediaController mediac;
VideoView video1;
mediac = new MediaController(this);
mediac.setAnchorView(video1);
video1 = (VideoView) findViewById(R.id.videoView1);
video1.setMediaController(mediac);
video1.setVideoPath("android.resource://video.test/raw/vid");
It plays fine on my ZTE Blade but on an Evo, GS2 and a Galaxy S , it says soryy, cannot play this video

Try with
video_view.setVideoURI(Uri.parse(path));
Sometimes passing directly as a string path doesn't work on some devices. The code which is working fine for me :
path = Environment.getExternalStorageDirectory() + "/file_name";
// Add controls to a MediaPlayer like play, pause.
MediaController mc = new MediaController(this);
video_view.setMediaController(mc);
// Set the path of Video or URI.
video_view.setVideoURI(Uri.parse(path));
// Set the focus.
video_view.requestFocus();
video_view.start();

Related

android Videoview not playing .sdp files what should i do?

I am making live tv channel streaming app.
But when i try to play the .sdp files in the android videoview it gives the error that "Sorry can't play this video".But it is playing .mp4 and .3gp videos successfully.
What should i do.I googled alot but in vain.
String VideoURL = "rtsp://pull.newclear.tv/live/livestream2_160p";
//"rtsp://pull.newclear.tv/live/livestream2_160p";
//.sdp links are also giving same error
//links of above type are not working
This is my code for videoview
MediaController mediacontroller = new MediaController(
VideoViewActivity.this);
mediacontroller.setAnchorView(videoview);
// Get the URL from String VideoURL
Uri video = Uri.parse(VideoURL);
videoview.setMediaController(mediacontroller);
videoview.setVideoURI(video);

RTSP video link is not playing smoothly in android

I am trying to build an android app that will stream video from RTSP web link. I have used vitamio library and video is streaming but the problem is, it is not streaming smoothly. Playback speed changes while streaming.
How to get rid from this?
Code is given below,
videoView = (VideoView) findViewById(R.id.VideoView);
videoView.setVideoURI(Uri.parse(liveUrl));
videoView.setOnBufferingUpdateListener(this);
videoView.setOnCompletionListener(this);
videoView.setOnCompletionListener(this);
videoView.setOnPreparedListener(this);
MediaController mediaController = new MediaController(this);
videoView.setMediaController(mediaController);
videoView.start();
videoView.setVideoQuality(-16);
videoView.setBufferSize(2048);
videoView.requestFocus();

android MediaPlayer for video. problems starting

how do i reference a video and play it using mediaPlayer and VideoViewer, when the file is in my raw folder
iv tried
videoview.setVideoPath("android.raw://com.example.movievp8");
as well as
MediaPlayer video1 = MediaPlayer.create(this, R.raw.movievp8);
once I have referenced it should i just hit video1.start();
also does anyone know where i could get like a full sample code on how to use media player for videos, just the basics.
Your code
MediaPlayer video1 = MediaPlayer.create(this, R.raw.movievp8);
video1.start();
should works (but you will only have audio).
One way to do it is using a VideoView (where your video will be displayed) and a MediaController (to have some predefined buttons such as Play, pause, stop, etc.)
VideoView vv = (VideoView) findViewById(R.id.videoview);
MediaController controller = new MediaController(vv.getContext());
vv.setMediaController(controller);
vv.setVideoURI(Uri.parse("android.resource://" + context.getPackageName() + "/" + videoID));
vv.start();
Remember that the simulator doesn't support video. You'll need to use a real device for testing video.

To play video files using MediaPlayer class in android

I want to play video files in my application which are part of my application.
for that i create 'raw' folder in 'res' and write following code in my activity.
MediaPlayer mp = MediaPlayer.create(VideoPlayer.this,R.raw.jeevrangala);
mp.start();
now i am testing it on emulator, but it does not displaying any thing.
is any one have solution to play video files in raw folder. please let me know.
Initial i was trying to play video files from raw folder. but cant run it. so i use another way to do this
VideoView video=(VideoView) findViewById(R.id.videoview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(video);
video.setMediaController(mediaController);
//Uri uri = Uri.parse("android.resource://play.vedio/"+R.raw.dobeernotdrugs);
video.setKeepScreenOn(true);
video.setVideoPath("android.resource://one.two/raw/"+resource);
video.start();
video.requestFocus();
resource is file name which you want to play and one.two is package name your path may as like
"android.resource://package_name/raw/file_name"
You can use this code to run video on emulator.. for me it is working
VideoView videoHolder = (VideoView) findViewById(R.id.video_view);
Uri video = Uri.parse("android.resource://" + getPackageName() + "/"
+ R.raw.samplevideo);
videoHolder.setVideoURI(video);
videoHolder.start();
And please turn on your graphics acceleration for the emulator..

Android Video Streaming

I need HTTP/RTSP Video Streaming with Android. Any Ideas ?
Is that possible to go with JMF with Android ? Any Working examples ?
Already tried with
http://davanum.wordpress.com/2007/12/29/android-videomusic-player-sample-from-local-disk-as-well-as-remote-urls/
Its not working with my case. Are there any specific types of videos that Android can stream ?
Thanks.
You don't necessarily need JMF. Android has built in support for HTTP/RTSP video streaming.
Try this:
String LINK = "type_here_the_link";
setContentView(R.layout.mediaplayer);
VideoView videoView = (VideoView) findViewById(R.id.video);
MediaController mc = new MediaController(this);
mc.setAnchorView(videoView);
mc.setMediaPlayer(videoView);
Uri video = Uri.parse(LINK);
videoView.setMediaController(mc);
videoView.setVideoURI(video);
videoView.start();

Categories

Resources