Java示例非常简单的播放器(JMF)
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java示例非常简单的播放器(JMF)相关的知识,希望对你有一定的参考价值。
package org.jmf.example; import javax.swing.JDialog; import javax.swing.JFrame; import javax.swing.UIManager; import javax.swing.UnsupportedLookAndFeelException; import javax.swing.plaf.metal.MetalLookAndFeel; public class ExampleJMF { { try { } { e.printStackTrace(); } new exampleFrame(); } } package org.jmf.example; import java.awt.Toolkit; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.swing.JFrame; { private static final long serialVersionUID = 1L; public exampleFrame() { super("JMF - Example..."); setSize(400, 300); { { } }); setContentPane(new examplePanel()); setVisible(true); } } package org.jmf.example; import java.awt.Component; import java.awt.Graphics; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import javax.media.ControllerEvent; import javax.media.ControllerListener; import javax.media.Manager; import javax.media.NoPlayerException; import javax.media.Player; import javax.media.RealizeCompleteEvent; import javax.swing.JPanel; { private static final long serialVersionUID = 1L; private Player player; public examplePanel() { try { player.addControllerListener(this); player.start(); } catch(NoPlayerException e) { e.printStackTrace(); } { e.printStackTrace(); } { e.printStackTrace(); } } { super.paintComponent(g); } { } public void controllerUpdate(ControllerEvent c) { if(player == null) return; if(c instanceof RealizeCompleteEvent) { if((visualComponent = player.getVisualComponent()) != null) add(visualComponent); } } }
以上是关于Java示例非常简单的播放器(JMF)的主要内容,如果未能解决你的问题,请参考以下文章