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?
Related
I have successfully stream ip camera on an android phone using rtsp using this code:
public class MainActivity extends Activity {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
VideoView video= (VideoView) findViewById(R.id.videoview);
String viewSource = "rtsp://192.168.1.........";
video.setVideoURI(Uri.parse(viewSource));
video.setMediaController(new MediaController(this));
video.requestFocus();
video.start();
}
}
My question is that is it possible to manipulate videoview on android using boofcv which is using ip camera? Because on boofcv samples it is using a built in camera on android phone. If someone is kind here can help me please.
Here is my code, and when I run the app, it will display "Sorry this video cannot be played".
public class rtspActivity extends Activity {
Button btn;
VideoView v;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_rtsp);
v=(VideoView)findViewById(R.id.vv);
v.setVideoURI(Uri.parse("rtsp://server.intelcast.tv:554/live/haditvfour1"));
}
}
You should start with
v.setMediaController(new MediaController(this));
v.requestFocus();
v.start();
Also, the url you're using might not be good. Try it in VLC or similar, to see if its actually there
Another problem can be the "server.intelcast.tv:554" part, try replacing this with a real ip adress with numbers, i've experinced this issue myself
I am new to android and want to play videos one after another simultaneously so that it looks like continuous video.
I have found this link on stackoverflow very helpful. how-to-play-videos-one-after-another-simultaneously
When I am using this then though I am able to play videos one after another,
But switching from one segment to other results in pause the video for a second before playing next one. So It don't looks like continuous videos due to this.
Please help me to resolve my problem.
Here is my Code.
public class VideoActivity extends Activity{
VideoView videoView, videoView1;
MediaController mc;
int count = 0;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
videoView = (VideoView) findViewById(R.id.VVSimpleVideo);
setup();
videoView.setOnCompletionListener(completionListener);
}
public void setup() {
String _path = "/mnt/sdcard/Video/"+count+".mp4";
videoView.setVideoPath(_path);
videoView.start();
count++;
}
private OnCompletionListener completionListener=new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mp.stop();
setup();
}
};
}
Now I have tried to play by taking two instances of VideoView class.
Tried to play the first video by first player and second video by second player,
Third video from first player and fourth video from second player and so on.
But still I am not able to play the video smoothly and the same problem exist.
Here is my code with double player.
public class VideoActivity extends Activity{
VideoView videoView, videoView1;
MediaController mc;
int count = 0;
String _path;
String _path1;
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_video);
videoView = (VideoView) findViewById(R.id.VVSimpleVideo);
_path = "/mnt/sdcard/Video/"+count+".mp4";
videoView.setVideoPath(_path);
videoView.start();
//setup();
videoView.setOnCompletionListener(completionListener);
videoView1 = (VideoView) findViewById(R.id.VVSimpleVideo);
videoView1.setOnCompletionListener(completionListener1);
count++;
_path1 = "/mnt/sdcard/Video/"+count+".mp4";
videoView1.setVideoPath(_path1);
}
public void setup() {
videoView.start();
count++;
_path1 = "/mnt/sdcard/Video/"+count+".mp4";
videoView1.setVideoPath(_path1);
}
public void setup1() {
videoView1.start();
count++;
_path = "/mnt/sdcard/Video/"+count+".mp4";
videoView.setVideoPath(_path);
}
private OnCompletionListener completionListener=new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mp.stop();
setup1();
}
};
private OnCompletionListener completionListener1=new OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
mp.stop();
setup();
}
};
}
You're not really using two VideoViews at all, you're assigning both VideoView and VideoView1 to R.id.VVSimpleVideo, so they are the same object. That means each time you hit onCompletion, it's setting itself up all over again, instead of setting up one and playing the other.
Try creating two separate VideoView objects in your layout. Have one set to VISIBLE and one set to GONE/INVISIBLE, and swap when you want to change.
I can't guarantee it will make it "seamless", though, since that's an almost impossible task. Even most desktop media players aren't truly seamless. It just depends on what tolerance you have for seams.
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.
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.