0
這是我的代碼更新JSlider的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());
}
但它不會改變位置事實上,它從頭再次開始播放和再次播放。我認爲原因是setTime()函數在jslider可以接受新值之前一直保持更新爲0.有任何解決方案可能使用線程? 謝謝!!
我會搜索後臺進程,並改變這一點,希望它會工作。感謝很多 – rishu