在我的应用程序中,从图库中选择视频并将其放入视频视图
<VideoView
android:id="@+id/videoview"
android:layout_width="fill_parent"
android:layout_height="300dp"
android:layout_below="@+id/rel_navbar"/>
每当我拖动自定义范围搜索栏时,我想移动视频位置,并且还可以移动位置来显示时间。
private void seekbar()
{
Log.e("mnvalue is","<><."+minvalue);
Log.e("maxvalue is","<><>"+maxvalue);
// TODO Auto-generated method stub
seekBar = new RangeSeekBar<Integer>(minvalue, maxvalue,this);
layout.addView(seekBar);
seekBar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Integer>()
{
@Override
public void onRangeSeekBarValuesChanged(RangeSeekBar<?> bar, Integer minValue,Integer maxValue)
{
// TODO Auto-generated method stub
Log.e("minvalue is","<><><>"+minValue);
Log.e("maxvalue is","<><><>"+maxValue);
minvalue1=minValue;
maxvalue1=maxValue;
trim=1;
int videoposition1=videoview.getCurrentPosition();
//int videoposition_1=videoposition1/1000;
Log.e("videopositopn is","<><>"+videoposition1);
videoview.seekTo(videoposition1);
}
});
}
但是当我拖动位置时,视频位置没有移动?请告诉我该怎么办? 提前谢谢..
答案 0 :(得分:0)
In RangeSeekbar class take two static int variables that is tempmin amd tempmax.
public final void trackTouchEvent(MotionEvent event) {
final int pointerIndex = event.findPointerIndex(mActivePointerId);
final float x = event.getX(pointerIndex);
if (Thumb.MIN.equals(pressedThumb))
{
Log.e("min value","minvalue");
tempmin=1;
tempmax=0;
Log.e("tempmin is","<><>"+tempmin);
setNormalizedMinValue(screenToNormalized(x));
}
else if (Thumb.MAX.equals(pressedThumb))
{
Log.e("max value","maxvalue");
tempmax=1;
tempmin=0;
Log.e("tempmax ix","<><>"+tempmax);
setNormalizedMaxValue(screenToNormalized(x));
}
}
In your Activity change the code as follows,
Videovirewfortrim是视频视频
videoviewfortrim.setOnPreparedListener(new OnPreparedListener()
{
@Override
public void onPrepared(MediaPlayer mp)
{
float minvalue=videoviewfortrim.getCurrentPosition();
final float maxvalue=videoviewfortrim.getDuration();
final RangeSeekBar<Float> seekbar = new RangeSeekBar<Float>(minvalue, maxvalue2,getParent());
layout.addView(seekbar);
seekbar.setOnRangeSeekBarChangeListener(new OnRangeSeekBarChangeListener<Float>()
{
@Override
public void onRangeSeekBarValuesChanged(
RangeSeekBar<?> bar, Float minValue,
Float maxValue)
{
if(RangeSeekBar.tempmin==1)
{
videoviewfortrim.seekTo((int) (minValue*1000));
if(seekbar.isPressed())
{
videoviewfortrim.pause();
imgviewplay.setVisibility(View.VISIBLE);
}
}
else if(RangeSeekBar.tempmax==1)
{
videoviewfortrim.seekTo((int) (maxValue*1000));
if(seekbar.isPressed())
{
videoviewfortrim.pause();
imgviewplay.setVisibility(View.VISIBLE);
}
}
}
}
}
}