package videopalyer2;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.*;
import java.io.*;
import java.net.MalformedURLException;
import java.net.URL;
public class VideoPlayerFrame extends JFrame{
private JMenuItem open,exit,loop,aboutus,help;
private JPanel JVideoPanel;
private JLabel videoName;
private boolean isLoop = false,first = true;
private File currentDirctory;
private URL url;
public VideoPlayerFrame(){
super("我的视频");
init();
this.setSize(600,450);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setLocationRelativeTo(null);
this.setVisible(true);
}
public void init(){
this.setJMenuBar(createBar());
JPanel contentPane = (JPanel)this.getContentPane();
JVideoPanel = new JPanel();
JVideoPanel.setLayout(new BorderLayout());
contentPane.add(JVideoPanel,BorderLayout.CENTER);
videoName = new JLabel();
contentPane.add(videoName,BorderLayout.SOUTH);
}
public JMenuBar createBar(){
JMenuBar menu_bar = new JMenuBar();
JMenu menu_file = new JMenu("文件(F)");
menu_file.setMnemonic(KeyEvent.VK_F);
open = new JMenuItem("打开(O)");
open.setAccelerator(KeyStroke.getKeyStroke('O', KeyEvent.CTRL_MASK));
open.addActionListener(new OpenListener());
exit = new JMenuItem("退出(X)...");
exit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
exit.setAccelerator(KeyStroke.getKeyStroke('X', KeyEvent.CTRL_MASK));
menu_file.add(open);
menu_file.add(exit);
JMenu menu_play = new JMenu("播放(P)");
menu_play.setMnemonic(KeyEvent.VK_P);
loop = new JCheckBoxMenuItem("循环(L)");
loop.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
isLoop = !isLoop;
}
});
menu_play.add(loop);
JMenu menu_help = new JMenu("帮助(H)");
menu_help.setMnemonic(KeyEvent.VK_H);
help = new JMenuItem("帮助");
aboutus = new JMenuItem("关于我们...");
menu_help.add(help);
menu_help.add(aboutus);
menu_bar.add(menu_file);
menu_bar.add(menu_play);
menu_bar.add(menu_help);
return menu_bar;
}
public JPanel getJVideoPanel() {
return JVideoPanel;
}
public void setJVisualPanel(Component com){
JVideoPanel.add(com,BorderLayout.CENTER);
}
public void setJControlPanel(Component com){
JVideoPanel.add(com,BorderLayout.SOUTH);
}
public JLabel getVideoName() {
return videoName;
}
public boolean getLoop() {
return isLoop;
}
class OpenListener implements ActionListener{
public void actionPerformed(ActionEvent e){
JFileChooser fileChooser = new JFileChooser();
if(!first){
fileChooser.setCurrentDirectory(currentDirctory);
}
first = false;
int rVal = fileChooser.showOpenDialog(VideoPlayerFrame.this);
if(rVal == JFileChooser.APPROVE_OPTION){
try {
url = fileChooser.getSelectedFile().getAbsoluteFile().toURI().toURL();
currentDirctory = fileChooser.getCurrentDirectory();
} catch (MalformedURLException e1) {
e1.printStackTrace();
}
System.out.println(url);
new VideoPlayer(VideoPlayerFrame.this,url);
}
if(rVal == JFileChooser.CANCEL_OPTION){
}
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
视频音频播放器:这是我编写的一个视频音频播放器,可以播放的音频有mp3,wav,视频是avi,其他格式要进行另外编码。我旨在理解...
共12个文件
class:7个
java:3个
classpath:1个
4星 · 超过85%的资源 需积分: 10 105 下载量 24 浏览量
2010-07-27
11:19:27
上传
评论 1
收藏 10KB RAR 举报
温馨提示
这是我编写的一个视频音频播放器,可以播放的音频有mp3,wav,视频是avi,其他格式要进行另外编码。我旨在理解JMF播放器的整体架构,了解播放器的各个状态。在运行前要先安装JMF,并把JMF包导进去,我已经倒进去了,可能要移除重新导入你所安装的
资源推荐
资源详情
资源评论
收起资源包目录
palyers.rar (12个子文件)
palyers
bin
videopalyer2
VideoPlayerFrame$2.class 882B
MainClass.class 446B
VideoPlayerFrame.class 4KB
VideoPlayer$PlayerListener.class 2KB
VideoPlayerFrame$OpenListener.class 2KB
VideoPlayerFrame$1.class 793B
VideoPlayer.class 2KB
src
videopalyer2
VideoPlayer.java 2KB
MainClass.java 132B
VideoPlayerFrame.java 3KB
.project 383B
.classpath 293B
共 12 条
- 1
jackie3901080311
- 粉丝: 0
- 资源: 16
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
- 1
- 2
前往页