这是我更新 jslider 的代码
try{
name=(String) jList1.getSelectedValue();
CanvasVideoSurface videoSurface = mediaPlayerFactory.newVideoSurface(canvas1);
mediaPlayer.setVideoSurface(videoSurface);
mediaPlayer.setAdjustVideo(true);
mediaPlayer.playMedia(name+".mp4");
mediaPlayer.setVolume(jSlider1.getMinimum());
mediaPlayer.parseMedia();
time = (int)(mediaPlayer.getMediaMeta().getLength()/1000);
jSlider2.setMaximum(time);
while(jSlider2.getValue()<jSlider2.getMaximum())
{
jSlider2.setValue((int) this.mediaPlayer.getTime()/1000);
}
}
catch(Exception e)
{
e.printStackTrace();
}
对于滑块的更改状态,这是代码
private void jSlider2StateChanged(javax.swing.event.ChangeEvent evt)
{
mediaPlayer.setTime((long) this.jSlider2.getValue());
}
但它不会改变 nob 的位置,事实上它会再次从头开始播放。我认为原因是 setTime() 函数在 jslider 可以获取新值之前不断更新为 0。有什么解决方案吗?也许使用线程? ? 谢谢!!