我是android的新手我想在这个视频播放器中开发视频播放器的应用我需要整合搜索栏。我陷入了这种情况。场景是寻求视频长度的搜索栏,在视频结束时(视频播放完毕)搜索栏设置为零plz帮助我如何实现这种情况。
我不知道如何实施
1)how to set seekbar seeking up to video length/duration
2)if video is fully played how to set seekbar in start position/initial position(before seeking video position)
3)how can i get video is fully played
请任何人尽快帮助我
答案 0 :(得分:1)
我发现这些链接可能对他们有所帮助:
How to play a video using videoview controlled by a seekBar or Progress bar?
How to use a Seekbar in android as a seekBar as well as a progressBar simultaneously?
How can i change the position of a progressBar, after the duration of a videoView?
package com.coderzheaven.pack;
import android.app.Activity;
import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
public class VideoViewDemo extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
showVideo();
}
private void showVideo()
{
VideoView vd = (VideoView)findViewById(R.id.videoview);
Uri uri = Uri.parse("android.resource://"+ getApplication().getPackageName() +"/"+R.raw.asal);
MediaController mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.start();
vd.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
//you can set seekbar position here with help of vd.seekTo(progress);
Toast.makeText(getApplicationContext(), "Video completed", Toast.LENGTH_LONG).show();
}
});
}
}
答案 1 :(得分:1)
1)如何设置搜索栏搜索视频长度/持续时间
您可以使用以下代码实现此目的:
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
long duration = videoView.getDuration();
}
});
如果这样可以将此标记为其他人帮助的答案