السلام عليكــم ورحمـة الله وبركاتــه ،،
حاولت عمل JMF media Player ولكن البرنامج بيشغل mp3 فقط
لكن مع الامتدادت الاخرى مثل mov,wmv,avi,rmvb
الرجاء مساعدتي في حل المشكلة
وهناك مشكلة اخرى ان ملف mp3 يظل يعمل بعد غلق الmediaplayer
هذا كود البرنامج
import java.awt.*;
import java.awt.event.*;
import javax.media.*;
import javax.swing.*;
import javax.media.bean.playerbean.*;
import java.net.*;
import java.io.*;
public class Media extends JFrame{
MediaPlayer mp=new MediaPlayer();
Player player;
public Media(){
playBack();
}
public void playBack(){
JPanel panel=new JPanel();
JPanel panel1=new JPanel();
try{
FileDialog fd=new FileDialog(this,"Open");
fd.setVisible(true);
String filename=fd.getFile();
String path=fd.getDirectory();
String extension=(filename.lastIndexOf(".")==-1)?"":filename.substring(filename.lastIndexOf(".")+1,filename.length());
System.out.println(extension);
String fullname=path+filename;
System.out.println(fullname);
File file=new File(fullname);
player=Manager.createPlayer(file.toURL());
mp.setSize(370,350);
mp.setLocation(50,10);
mp.setVisible(true);
mp.setBackground(Color.BLACK);
mp.setPlaybackLoop(false);
mp.setVolumeLevel("5");
mp.saveMediaTime();
mp.setCachingControlVisible(true);
mp.setControlPanelVisible(true);
mp.setPlayer(player);
JMenuBar bar=new JMenuBar();
JMenu filemenu=new JMenu("File");
JMenuItem item1=new JMenuItem("Play");
filemenu.add(item1);
bar.add(filemenu);
//Container con=this.getContentPane();
// this.add(bar,BorderLayout.NORTH);
this.add(mp);
// this.add(panel,BorderLayout.NORTH);
// this.add(panel1);
mp.setMediaLocation("<A href="file:///"+fullname">file:///"+fullname);
mp.start();
this.addWindowFocusListener(new Window());
this.setVisible(true);
this.setSize(370,350);}
catch(Exception es){
es.getMessage();
}
}
public static void main(String[]args){
new Media();
}
class Window extends WindowAdapter{
public void windowClosing(WindowEvent e){
System.out.println(e.getSource());
player.stop();
player.close();
}
}}
