这是我的问题,我正在使用以下使用JMF播放视频的java代码。如果我想播放视频的特定部分,可以说一个镜头(具有已知的开始时间和结束时间),如何做到这一点(如果你知道代码请在这里作为“方法”发布) 提前谢谢。
import java.awt.BorderLayout;
import java.awt.Component;
import java.io.IOException;
import java.net.URL;
import javax.media.*;
import javax.swing.*;
import javax.media.control.FramePositioningControl;
public class MediaPanel extends JPanel
{
public MediaPanel( URL mediaURL )
{
FramePositioningControl fpc;
setLayout( new BorderLayout() ); =
Manager.setHint( Manager.LIGHTWEIGHT_RENDERER, true );
try
{
Player mediaPlayer = Manager.createRealizedPlayer( mediaURL );
Component video = mediaPlayer.getVisualComponent();
Component controls = mediaPlayer.getControlPanelComponent();
if ( video != null )
add( video, BorderLayout.CENTER );
if ( controls != null )
add( controls, BorderLayout.SOUTH );
mediaPlayer.start();
}
catch ( NoPlayerException noPlayerException )
{
System.err.println( "No media player found" );
}
catch ( CannotRealizeException cannotRealizeException )
{
System.err.println( "Could not realize media player" );
}
catch ( IOException iOException )
{
System.err.println( "Error reading from the source" );
}
}
}
答案 0 :(得分:0)
查看JMF播放器API setMediaTime()
和setStopTime()