首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > J2SE开发 >

用java写的一个容易的播放器运行却爆没有权限操作文件!有遇到过的大神么

2013-12-06 
用java写的一个简单的播放器运行却爆没有权限操作文件!有遇到过的大神么用java写的一个简单的播放器运行却

用java写的一个简单的播放器运行却爆没有权限操作文件!有遇到过的大神么
用java写的一个简单的播放器运行却爆下面的错误!说没有权限操作!求教如何才能 解决

java.io.IOException: Permission Denied: From an applet cannot read media file with extension wmv
java.io.IOException: Permission Denied: From an applet cannot read media file with extension wmv
Got exception javax.media.NoPlayerException: Error instantiating class: com.sun.media.protocol.file.DataSource : java.io.IOException: Permission Denied: From an applet cannot read media file with extension wmv
java.lang.NullPointerException
at PlayDome.start(PlayDome.java:40)
at sun.applet.AppletPanel.run(AppletPanel.java:464)
at java.lang.Thread.run(Thread.java:619)


import java.applet.Applet;
import java.awt.BorderLayout;
import java.awt.Component;

import javax.media.ControllerEvent;
import javax.media.ControllerListener;
import javax.media.Manager;
import javax.media.MediaLocator;
import javax.media.Player;
import javax.media.RealizeCompleteEvent;


public class PlayDome extends Applet implements ControllerListener {
  /**
     * Playing an MPEG Movie in an Applet
     */
    private static final long serialVersionUID = 1L;

    Player player = null;

    public static void main(String[] args) {
new PlayDome().init();
}
    public void init() {
           setLayout(new BorderLayout());
           MediaLocator mrl = new MediaLocator(new java.lang.String(
                         "file:///E:\\XLMMS.wmv"));
           
           try {

                  player = Manager.createPlayer(mrl);
                  //System.out.println("test1:" + player);
                  player.addControllerListener(this);
           } catch (Exception e) {
                  System.err.println("Got exception " + e);
           }
    }

    public void start() {
           player.start();
    }

    public void stop() {
           player.stop();
           player.deallocate();
    }

    public void destroy() {
           player.close();
    }

    public synchronized void controllerUpdate(ControllerEvent event) {
           if (event instanceof RealizeCompleteEvent) {
                  Component comp;
                  if ((comp = player.getVisualComponent()) != null)
                         add("Center", comp);
                  if ((comp = player.getControlPanelComponent()) != null)
                         add("South", comp);
                  validate();
           }
    }

}
JMV media 播放器 java


[解决办法]
From an applet cannot read media file with extension wmv

你换个后缀试试

这个意思是说 applet不能读后缀是 wmv的 媒体文件
[解决办法]
要注册ext的吧。
看下源码为什么会报第一个异常:


// For applets, check to see if the media file has a file extension  
    // If not, throw an IOException with the following message:  
    // "For security reasons, from an applet, cannot read a media file with no extension"  
    // If there is a file extension, make sure it is registered in the  
    // mimetable.  
    // If not throw an IOException.  
  
    if (jmfSecurity != null) {  
        int i = fileName.lastIndexOf(".");  
        if (i != -1) {  
        String ext = fileName.substring(i+1).toLowerCase();  
        if (!mimeTable.containsKey(ext)) {  
            // Treat aif as a special case due to bug in IE VM  
            if (!ext.equalsIgnoreCase("aif"))   
            throw new IOException("Permission Denied: From an applet cannot read media file with extension " + ext);  
        }  
        } else {  
        throw new IOException("For security reasons, from an applet, cannot read a media file with no extension");  
        }  
    }  

热点排行