我目前正在与JMF一起玩,以将视频嵌入到我的GUI中。我的课程很好看,但是我却不断收到奇怪的堆栈跟踪信息,这使我挠头。

Failed to configure: com.sun.media.PlaybackEngine@1fc4bec
  Bad header in the media: IOException when parsing hdrl

Error: Unable to realize com.sun.media.PlaybackEngine@1fc4bec
javax.media.CannotRealizeException
    at javax.media.Manager.blockingCall(Manager.java:2005)
    at javax.media.Manager.createRealizedPlayer(Manager.java:554)
    at EmbeddedPlayer.<init>(EmbeddedPlayer.java:24)
    at MenuFrame.addMedia(MenuFrame.java:142)
    at ConfigReader.parse(ConfigReader.java:362)
    at ConfigReader.findFrames(ConfigReader.java:60)
    at ConfigReader.main(ConfigReader.java:32)
Exception in thread "main" java.lang.NullPointerException
    at EmbeddedPlayer.<init>(EmbeddedPlayer.java:35)
    at MenuFrame.addMedia(MenuFrame.java:142)
    at ConfigReader.parse(ConfigReader.java:362)
    at ConfigReader.findFrames(ConfigReader.java:60)
    at ConfigReader.main(ConfigReader.java:32)
seek: java.io.IOException: Negative seek offset


我仅用Java进行开发一年,但我不确定现在的轨迹告诉我什么。

任何帮助,甚至只是告诉我正在发生的事情都将大有帮助。

这是EmbeddedPlayer:

import java.awt.BorderLayout;
import java.awt.Component;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.swing.JPanel;

@SuppressWarnings("serial")
public class EmbeddedPlayer extends JPanel {

    private MenuFrame parent;
    public static final String DEFAULT_MEDIA_PATH = "media/";

    public EmbeddedPlayer(MenuFrame parent, String file) {
        this.parent = parent;
        setLayout( new BorderLayout() );
        Manager.setHint(Manager.LIGHTWEIGHT_RENDERER, true);

        Player mediaPlayer = null;
        Component video = null;
        Component controls = null;
        try {
            MediaLocator location = new MediaLocator(file);
            mediaPlayer = Manager.createRealizedPlayer(location);
            video = mediaPlayer.getVisualComponent();
            controls = mediaPlayer.getControlPanelComponent();
        } catch (Exception e) {
            e.printStackTrace();
        }

        if ( video != null ) { add(video, BorderLayout.CENTER); }
        if ( controls != null ) { add(controls, BorderLayout.SOUTH); }

        this.parent.add(this);
        mediaPlayer.start();
    }
}


根据以下示例:http://www.deitel.com/articles/java_tutorials/20060422/PlayingVideowithJMF/

最佳答案

我相信EmbeddedPlayer是您的代码(而不是jmf),因此您需要在EmbeddedPlayer.java的第35行中检查引用了哪个对象。或发布EmbeddedPlayer的代码。

更新:问题似乎无法创建播放引擎。
也许这个网址会帮助http://blog.msbbc.co.uk/2007/06/mp3-playback-in-java.html

10-08 05:45