Can't play this video - android

When i want to play video from sdcard can't play this video error is shown
the code is
public class MainActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView vv = (VideoView) findViewById(R.id.videoView);
vv.setVideoPath("/sdcard/idayam.mp4");
vv.setMediaController(new MediaController(this));
vv.start();
vv.requestFocus();
}
}and my LogCat error is
07-28 16:52:26.874: E/MediaPlayer(23466): error (1, -2147483648)

Change
vv.setVideoPath("/sdcard/idayam.mp4");
to
vv.setVideoPath(Environment.getExternalStorageDirectory().getAbsolutePath() + "/idayam.mp4");
The path that you are providing is not a valid one. You should always use Environment.getExternalStorageDirectory().getAbsolutePath() to get the path of the SD card

Related

Videoview is not playing .3gp file

I am trying to play .3gp file from a live RTSP. following is my code,
public class MainActivity extends Activity
{
// String path = "rtsp://v5.cache1.c.youtube.com/CjYLENy73wIaLQnhycnrJQ8qmRMYESARFEIJbXYtZ29vZ2xlSARSBXdhdGNoYPj_hYjnq6uUTQw=/0/0/0/video.3gp";
String path = "rtsp://217.146.95.166:554/live/ch12zqcif.3gp";
VideoView videoView = null;
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView =(VideoView)findViewById(R.id.videoView);
videoView.setVideoURI(Uri.parse(path));
videoView.setMediaController(new MediaController(this));
videoView.requestFocus();
videoView.start();
}
#Override
public void onBackPressed()
{
super.onBackPressed();
if ( videoView != null )
{
videoView.pause();
videoView = null;
}
}
}
I have given INTERNET Permission in my AnroidManifest.xml file.
When I load the first path variable with Youtube one, it is working file and loading the video but the second RTSP url is not working.
What could be the problem for this..?
May be the problem is with you is your URL please verify the rtsp url. Here is the example for how to playvideo with the videoview.
Cheers

Media Player error when playing Video in Emulator

I'm trying to play video from youtube using this code but I get this error from my log cat:
06-28 16:23:09.794: E/MediaPlayer(621): error (1, -2147483648)
Here is my code:
public class PromoActivity extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(com.frux.kfcmobile.R.layout.promo);
VideoView videoView = (VideoView)this.findViewById(com.frux.kfcmobile.R.id.videoView);
String path = "rtsp://v4.cache5.c.youtube.com/CjYLENy73wIaLQmofK96HM6gyhMYDSANFEIJbXYtZ29vZ2xlSARSBWluZGV4YJWAl-O04anmTww=/0/0/0/video.3gp";
Uri vid = Uri.parse(path);
videoView.setVideoURI(vid);
videoView.setMediaController(new MediaController(this));
videoView.start();
videoView.requestFocus();
}
}
Can anyone help me?
Try this code
video.setVideoURI(Uri
.parse("rtsp://v6.cache7.c.youtube.com/CiILENy73wIaGQk-fYZWNAPDsxMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"));
mMediaController = new MediaController(this);
mMediaController.setMediaPlayer(video);
video.start();
And you try to run in Device.. Because in emulator only some videos will get played.

HTML5 Video Android VideoView

I am trying to play a video that is passed from a WebView in a VideoView. It works, except VideoView does not want to read it. I keep getting the error:
"Sorry, this video cannot be played."
Here is the code for the VideoView:
public class VideoHandler extends Activity {
WebView myWebView;
VideoView myVideoView;
WebChromeClient chromeClient;
WebViewClient wvClient;
Intent in;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.video_player);
myVideoView = (VideoView) findViewById(R.id.videoview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(myVideoView);
String video = (MNWVMainPage.myWebView.getUrl());
myVideoView.setMediaController(mediaController);
myVideoView.setVideoPath(video);
myVideoView.start();
myVideoView.setOnCompletionListener(new OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
mp.stop();
mp.release();
setContentView(R.layout.mnwv_main);
}
});
}
}
Why wont this load the video?
From just reading from your code, I can see no error.
Can you check a few things:
Does the video align to the format list here?
Have you open the camera/ another VideoView? Even if you release them, the buffer seems to need some time to be actually released.

not able to play video in the emulator

public class VideoViewActivity extends Activity {
private String vSource;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videoviewacti);
VideoView vView = (VideoView)findViewById(R.id.videovw);
vView.requestFocus();
String LINK = ConstantData.urlVideo;
Log.i("path of video",""+LINK);
vView.setVideoURI(Uri.parse(LINK));
//vView.setVideoPath("sdcard/test30fps.mp4");
MediaController mediacontroller = new MediaController(this);
vView.setMediaController(mediacontroller);
vView.start();
}
}
here the video doesn't play in the emulator.It shows the error like "Can not play video"
video format is mp4 on the webservice.
when it opens the video file then the controls of the mediaplayer get disabled.

Android-Media Player

I am new to android. I am trying to play a video from sdcard.
this is the sample code I have used:
public class videoa extends Activity {
/** Called when the activity is first created. */
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main);
VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
// (1) Web
//videoView.setVideoURI(Uri.parse(
//"http://www.bogotobogo.com/Video/sample.3gp"));
//"http://www.bogotobogo.com/Video/sample.mp4"));
//"http://www.bogotobogo.com/Video/sample.mov"));
/* (2) SD card */
//videoView.setVideoPath("/sdcard/sample.3gp");
videoView.setVideoPath("/sdcard/robot.avi");
//videoView.setVideoPath("/sdcard/sample.mov");
// videoView.setVideoURI(Uri.parse(
//"file:///sdcard/sample.mov"));
videoView.requestFocus();
videoView.start();
}
}
I have launched manually And set the target as -sdcard C:/android-sdk-windows/tools/sdcard.img.
When i have launched the emulator it shows Video Cannot be Displayed.
Please help me out.
You try interchanging the 2 lines
final String MEDIA_PATH = new String("/sdcard/robot.avi");
VideoView videoView = (VideoView)this.findViewById(R.id.videoView);
MediaController mc = new MediaController(this);
videoView.setVideoPath(MEDIA_PATH);
videoView.setMediaController(mc);
videoView.requestFocus();
videoView.start();

Categories

Resources