javax.media.* 包怎么引入不了啊 高手给看看
这个程序可以播放flash吗 ? 谁有能播放flash的例子! 谢谢哈
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.media.*; 就这个javax.media.* 引入不了怎么回事
public class PlayMusic
{
public static void main(String[] args)
{
PlayerFrame aPlayerFrame = new PlayerFrame();
aPlayerFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
aPlayerFrame.setVisible(true);
}
}
class PlayerFrame extends JFrame
{
public PlayerFrame()
{
setTitle("Play a music");
setSize(DEFAULT_WIDTH, DEFAULT_HEIGHT);
// add the menu and the Open and Exit menu items
JMenuBar menuBar = new JMenuBar();
JMenu menu = new JMenu("File");
JMenuItem openItem = new JMenuItem("Open");
menu.add(openItem);
openItem.addActionListener(new OpenAction());
JMenuItem exitItem = new JMenuItem("Exit");
menu.add(exitItem);
exitItem.addActionListener(new
ActionListener()
{
public void actionPerformed(ActionEvent event)
{
System.exit(0);
}
});
menuBar.add(menu);
setJMenuBar(menuBar);
}
void DealFile(String FileName)
{
try
{
File sourceFile = new File(FileName);
if (audioPlayer != null)
{
audioPlayer.stop();
audioPlayer.close();
}
audioPlayer = Manager.createRealizedPlayer(sourceFile.toURI().toURL());
audioPlayer.start();
}
catch(NoPlayerException e)
{
MyErrorDialog errorDialog = new MyErrorDialog(PlayerFrame.this,"File format");
errorDialog.setVisible(true);
}
catch(Exception e)
{
MyErrorDialog errorDialog = new MyErrorDialog(PlayerFrame.this,"Bad File Name");
errorDialog.setVisible(true);
}
}
private class OpenAction implements ActionListener
{
public void actionPerformed(ActionEvent event)
{
JFileChooser chooser = new JFileChooser();
chooser.setCurrentDirectory(new File("."));
chooser.addChoosableFileFilter(new FileFilter()
{
public boolean accept(File f)
{
return f.getName().toLowerCase().endsWith(".au") || f.isDirectory();
}
public String getDescription()
{
return "sun media(*.au)";
}
});
chooser.addChoosableFileFilter(new FileFilter()
{
public boolean accept(File f)
{
return f.getName().toLowerCase().endsWith(".wav") || f.isDirectory();
}
public String getDescription()
{
return "sound wave(*.wav)";
}
});
chooser.addChoosableFileFilter(new FileFilter()
{
public boolean accept(File f)
{
return f.getName().toLowerCase().endsWith(".mp3") ||
f.getName().toLowerCase().endsWith(".mp2") ||
f.getName().toLowerCase().endsWith(".mp1") ||
f.isDirectory();
}
public String getDescription()
{
return "mpeg media(*.mp1, *.mp2, *.mp3)";
}
});
int r = chooser.showOpenDialog(PlayerFrame.this);
if (r == JFileChooser.APPROVE_OPTION)
{
name = chooser.getSelectedFile().getPath();
DealFile(name);
}
}
}
public static final int DEFAULT_WIDTH = 400;
public static final int DEFAULT_HEIGHT = 300;
private String name;
private Player audioPlayer;
}
class MyErrorDialog extends JDialog
{
MyErrorDialog(Frame ownFrame, String message)
{
super(ownFrame, "Error occorred", true);
setLocationRelativeTo(ownFrame);
JPanel aPanel = new JPanel();
JLabel aLabel = new JLabel(message+" error");
aPanel.add(aLabel);
JButton ok = new JButton("OK");
ok.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent event)
{
setVisible(false);
}
});
add(aPanel, BorderLayout.CENTER);
add(ok, BorderLayout.SOUTH);
pack();
}
}