这是我的问题,我使用以下java代码使用JMF播放视频。如果我想播放视频的特定部分,比如一个镜头(已知开始时间和结束时间),如何做到这一点(如果你知道代码,请将其作为"方法"发布在这里)提前谢谢。
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" );
}
}
}
查看JMF播放器API setMediaTime()
和setStopTime()