- - PR -
jmf 動画再生がアプレットなら出来るが、アプリケーションではダメ
1
| 投稿者 | 投稿内容 |
|---|---|
|
投稿日時: 2004-03-02 15:24
jmfを使って、動画再生機能をチェックしています。
sunのホームページのサンプルアプレットでは、動画再生に成功しますが、 アプリケーションのサンプルでは、以下のエラーが出ます。 「Error: Unable to realize com.sun.media.amovie.AMController@80d1ff」 なお、幾つかのサンプルソースを拾ってきて試しましたが、上記と同じエラーになります。 どなたか、解る人おられませんか? 以下長くなりますが、ソースを示します。 //JMFPlayer.java --------------------------------------------------------- import java.awt.*; import java.awt.event.*; import java.net.*; import javax.media.*; import javax.swing.*; /** This is a simple generic media player it can be constructed with a URL format string and loads an appropriate player. */ public class JMFPlayer extends JFrame implements ControllerListener { Player player = null; /** Constructs a player to render the media stream which is read from the specified source. @param mediaSource The source from which to read the media data in a form suitable for construction of a URL. */ public JMFPlayer(String mediaSource) { Container content = getContentPane(); content.setLayout(new BorderLayout()); setTitle("JMFPlayer: " + mediaSource); try { URL mediaURL = new URL(mediaSource); player = Manager.createPlayer(mediaURL); player.addControllerListener(this); } catch (Exception e) { e.printStackTrace(); } // Layout the window at an initial size and make visible content.add(createControls(), BorderLayout.NORTH); setSize(300, 150); validate(); setVisible(true); // Trap the window close button as synonymous with the "Exit" button addWindowListener( new WindowAdapter() { public void windowClosing(WindowEvent event) { destroyPlayer(); System.exit(0); } } ); } ////////////////////////////////////////////////////////////////////////// /** Creates a control panel and connects the "Start", "Stop" and "Exit" buttons to the appropriate callback handler methods. */ public JPanel createControls() { JPanel panel = new JPanel(new FlowLayout()); JButton start = new JButton("Start"); start.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { startPlayer(); } } ); panel.add(start); JButton stop = new JButton("Stop"); stop.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { stopPlayer(); } } ); panel.add(stop); JButton exit = new JButton("Exit"); exit.addActionListener( new ActionListener() { public void actionPerformed(ActionEvent event) { destroyPlayer(); System.exit(0); } } ); panel.add(exit); return panel; } ////////////////////////////////////////////////////////////////////////// /** This callback handler function starts the player playing as soon as possible. */ public void startPlayer() { player.start(); } ////////////////////////////////////////////////////////////////////////// /** This callback handler function not only stops the player playing but also instructs it to free any memory (and other) resources that it might have allocated. This is the sort of suspension suitable for an applet that has been scrolled out of view.<P> The player can still be restarted by a subsequent call to startPlayer() but may take a little longer to restart since it must reinitialise any resource which it uses. */ public void stopPlayer() { player.stop(); player.deallocate(); } ////////////////////////////////////////////////////////////////////////// /** Closes down a player in preparation for shutdown of this application. */ public void destroyPlayer() { player.close(); } ////////////////////////////////////////////////////////////////////////// /** This method listens for events generated by the player during operation. It only handles "RealizeCompleteEvent" events but is able to report other types. */ public synchronized void controllerUpdate(ControllerEvent event) { if (event instanceof RealizeCompleteEvent) { Container content = getContentPane(); Component comp = player.getVisualComponent(); if (comp != null) content.add(comp, BorderLayout.CENTER); comp = player.getControlPanelComponent(); if (comp != null) content.add(comp, BorderLayout.SOUTH); // Adjust the windows size to reflect the newly added visual and // control components setSize(content.getPreferredSize()); validate(); } //System.out.println(event); } ////////////////////////////////////////////////////////////////////////// /** Create a separate player window for each of the command line arguments. */ public static void main(String[] args) { for (int i = 0; i < args.length; i++) new JMFPlayer(args[i]); } } |
|
投稿日時: 2004-03-02 17:27
すいません。半自己解決しました。
http://cappuccino.jp/keisuken/java/jmf.html のサンプルソースでは、アプリケーションでも動画再生できました。 原因はまだ良く解りませんが、これから調べてみます。 |
1
