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

林尹 2013-11-12 03:29:42
用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();
}
}

}
...全文
237 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
林尹 2013-12-06
  • 打赏
  • 举报
回复
问题自己解决了 是需要放 avi MJPEG PCM 格式的avi视频
林尹 2013-11-12
  • 打赏
  • 举报
回复
引用 3 楼 huxiweng 的回复:
要注册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");  
        }  
    }  
注册ext怎么弄?? 这个我是小白 能给段代码我看看么
teemai 2013-11-12
  • 打赏
  • 举报
回复
要注册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");  
        }  
    }  
林尹 2013-11-12
  • 打赏
  • 举报
回复
引用 1 楼 songbgi 的回复:
From an applet cannot read media file with extension wmv 你换个后缀试试 这个意思是说 applet不能读后缀是 wmv的 媒体文件
用avi 会爆下面的错误 也就是 不识别 Unable to handle format: XVID, 1424x800, FrameRate=15.0, Length=1708800 0 extra bytes Unable to handle format: mpeglayer3, 44100.0 Hz, 0-bit, Stereo, Unsigned, 16000.0 frame rate, FrameSize=8 bits Failed to realize: com.sun.media.PlaybackEngine@1982fc1 Error: Unable to realize com.sun.media.PlaybackEngine@1982fc1
  • 打赏
  • 举报
回复
From an applet cannot read media file with extension wmv 你换个后缀试试 这个意思是说 applet不能读后缀是 wmv的 媒体文件

62,614

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧