not able to play video in the emulator - android

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.

Related

Play RTSP streaming in an Android application, The live is coming back

I'm doing an android app that plays video from live camera.
I can watch live, but it comes back 1.5 seconds.
We do not want.
I used standard settings:
public class MainActivity extends AppCompatActivity {
VideoView videoView;
String videoUrl = "rtsp://admin:admin#192.168.1.125/live/0/h264.sdp";
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
videoView = (VideoView) this.findViewById(R.id.rtspVideo);
RtspStream(videoUrl);
}
private void RtspStream(String rtspUrl) {
videoView.setVideoURI(Uri.parse(rtspUrl));
videoView.setZOrderOnTop(false);
videoView.requestFocus();
videoView.postInvalidateDelayed(0);
videoView.start();
}
}
I think it's about buffer.
How can I solve the problem of coming back?
how can the library or application settings be used?

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

How to play rtsp live stream from android? (rtsp://someserver:port/live/001204A006F5.stream)

I have this video url rtsp://someserver:port/live/001204A006F5.stream and wanted to play the same from android media player. I have written following code snippet but android is showing a dialog box with the msg "Can't play this video".
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);`
videoPlayer = (VideoView) findViewById(R.id.videoPlayer);
videoPlayer.setOnPreparedListener(this);
videoPlayer.setOnCompletionListener(this);
videoPlayer.setKeepScreenOn(true);
Uri uri = Uri.parse("rtsp://someserver:port/live/001204A006F5.stream");
videoPlayer.setVideoURI(uri);
}
/** This callback will be invoked when the file is ready to play */
public void onPrepared(MediaPlayer vp) {
if(videoPlayer.canSeekForward()) videoPlayer.seekTo(videoPlayer.getDuration()/5);
videoPlayer.start();
}
Am I doing something wrong? Or it is not possible to play that link with VideoView?

Playing video in android directly from server

I am currently playing a video in andriod from the url http://daily3gp.com/vids/747.3gp
its working successfully.
But here i need to play that url through server, please let me know how to play.
Find the code below:
CODE
public class Activity3 extends Activity {
private VideoView videoView;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setContentView(R.layout.main2);
videoView = (VideoView)this.findViewById(R.id.videoView_surface_1);
MediaController mc = new MediaController(this);
videoView.setMediaController(mc);
videoView.setVideoURI(Uri.parse("http://daily3gp.com/vids/747.3gp"));
videoView.requestFocus();}}
Thanks for your Time!!
You have to call videoview.start() after this call only videoview will start playing video.

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.

Categories

Resources