Video player in android programming - android

Hi I wanna make a application by eclipse and I need to pause a Clip in a special time for example I wanna pause a clip in 2:30 and i don't know how can I do that please help me

Add following
videoView.postDelayed(new Runnable() {
#Override
public void run() {
videoView.pause();
}
}, 150000);

Related

Control the playback time of a video

I'm playing a video in ExoPlayer. Now I want to distribute a specific time for that video to the user so that the user chooses.
For example, I only want to display 30 seconds to 50 seconds.
In AndroidStudio and JAVA language.
Thanks for helping me
It's not related to ExoPlayer! You can handle it on your own.
So use this snippet to solve this problem:
At the same time with starting video:
videoview.seekTo(SPECIFIED_START_TIME);
Then run this handler:
handler = new Handler();
runnable = new Runnable() {
#Override
public void run() {
if(videoview.getCurrentPosition() >= DESTINATION_TIME){ // After reaching destination time
videoview.seekTo(SPECIFIED_START_TIME);
videoview.pause(); // or stop();
}
}
};
handler.postDelayed(runnable, 0);

VideoView turn into black screen

I am developing multi player video app, so in that i created 9 views 3*3.
when i initialize all (3*3) videoview then working properly for few seconds and after some time video is goes to black screen, not show single video, i am not understand this issue is device oriented or android not supports more than 1 video in activity, anyone know how to resolve this issue, otherwise if video is turn into black then how to identify video is turned into black screen, if we found this then i will refresh view and again start video, i don't know it is correct way or not.
please anyone know about how to resolve this issue then please share information !
i use below code for show multiple video view in one activity
videoPlayer.setVideoPath("path");
videoPlayer.start();
videoPlayer.requestFocus();
videoPlayer.setKeepScreenOn(true);
set prepare listener
videoPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
}
set completion listener
videoPlayer.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
#Override
public void onCompletion(MediaPlayer mp) {
//play next
}
});
handle error listener
videoPlayer.setOnErrorListener(new MediaPlayer.OnErrorListener() {
#Override
public boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
// play next
return true;
}
});
when video play next before that i set some propertied to mediaplyer object
mediaPlayer.setDisplay(null);
mediaPlayer.reset();
mediaPlayer.setDisplay(videoPlayer.getHolder());
i share basic code of my project, please tell me if anything is missing from me or android is not supported multiple videos in same activity.

Controlling video playback speed during online video streaming in android

I am to play video in android from Vimeo doing online streaming. For this, Right now, I am using VideoView. Now, I wanna control the video playback speed control feature like: 0.5x,1x,1,5x,2x And video cache support.
Are both of these possible with Android VideoView or is there any third player that I can use?
Help!
Hi for the best control i advice you with vlc lib or pvPlayer. or you can use this simple code but it dosen't work well.
public void slowMotion(){
final Handler handler = new Handler();
Runnable r = new Runnable() {
#Override
public void run() {
if (videoview != null) {
if (videoview.isPlaying()){
videoview.pause();
}
else{
videoview.start();
}
}
handler.postDelayed(this, 50);
}
};
handler.postDelayed(r, 800);
}
Good luck :D

How do I watch for VidoeView onStop() action?

I would like to trigger an event when my VideoView is done playing? How woudl I do this? can you show me an example or direct my to some resources?
Im thinking something like this.
if(!videoView.isplaying()){
//trigger event
}
or
public void onStop(){
//trigger event
}
If you want to know when play has completed, you would use VideoView.setOnCompletionListener().
myVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener(){
#Override
public void onCompletion(MediaPlayer mp){
// do on completion stuff.
}
});
If you want to detect error cases, you would use VideoView.setOnErrorListener() instead.

Android VideoView repetition

I have an application with a VideoView, in order to make the video play on a loop I use an onCompletionListner to call setVideoPath() again, like this:
mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer arg0) {
mVideoView.start();
}
});
mVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
public void onCompletion(MediaPlayer mp) {
//I have a log statment here, so I can see that it is making it this far.
mp.reset(); // <--- I added this recently to try to fix the problem
mVideoView.setVideoPath(file.getAbsolutePath());
}
});
This setup works well on all devices I've come across so far, I never had any trouble with it not repeating.
However the Motorola Xoom that I am testing on was recently upgraded to ICS. Now that it is on ICS this will work for a while and loop the video. But eventually (I've added a counter and some Logs, there does not appear to be any pattern to how many times it successfully loops before stopping) it will quit looping and just sit on a freeze frame of the first frame in the movie.
Does anyone know what could cause this not to loop properly any more? OR does anyone know of another way to get a VideoView to loop properly that does work under ICS still?
If you have only one video to play you can setLooping(true) in your on prepared listener.
myVideoView.setOnPreparedListener(new OnPreparedListener() {
#Override
public void onPrepared(MediaPlayer mp) {
// TODO Auto-generated method stub
mp.setLooping(true);
}
});
and you're done.
So far this:
mp.reset();
inside the onComplete callback seems to fix it. Would be very interested if anyone can explain what is going on with it.

Categories

Resources