b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

从“res”播放视频文件夹在eclipse中工作得很高,但不是从可执行文件JAR文件

电脑杂谈  发布时间:2019-08-24 21:08:39  来源:网络整理

视频播放器jar版_李宗瑞视频播放手机版下载_哈弗h5经典版视频播放

Google Facebook Youtube 科学上网》戳这里《

百度翻译此文有道翻译此文

问 题

i have an .MP4 video placed in the "res/media" folder inside my project. I can easily play this video in my application from eclipse using this piece of code:

String url = getClass().getResource("/media/video.mp4").getFile();
url = new File(url).getPath();
showMedia(url);       //the method that plays the video

i had to use this code because using only URL url = getClass().getResource("/media/video.mp4"); makes VLCJ can't access the video using this URL.

When creating the executable JAR file, i get these errors in the console:

libdvdnav: Using dvdnav version 5.0.0
libdvdread: Could not open D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 with libdvdcss.
libdvdread: Can't open D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 for reading
libdvdnav: vm: failed to open/read the DVD
[1644d0ac] filesystem access error: cannot open file D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 (Invalid argument)
[1644d0ac] main access error: File reading failed
[1644d0ac] main access error: VLC could not open the file "D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4" (Invalid argument).
[1645643c] main input error: open of `file:///D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4' failed
[1645643c] main input error: Your input can't be opened
[1645643c] main input error: VLC is unable to open the MRL 'file:///D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4'. Check the log for details.

The libraries are being successfully loaded, and i can even play any video that is outside my JAR file.

Any suggestions?

And thanks in advance.

解决方案

A Media Resource Locator (MRL) is not the same as a URL.

The log you posted shows what VLC is trying to open. The informative part is:

[1644d0ac] filesystem access error: cannot open file D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4 (Invalid argument)

"D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4" is clearly not a valid filename?

So this code is flawed:

String url = getClass().getResource("/media/video.mp4").getFile();

This type of thing, without the .getFile(), is usually used to load resources from the application classpath. That's not the case here though when you try and get the file name.

You should just do something like:

视频播放器jar版_李宗瑞视频播放手机版下载_哈弗h5经典版视频播放

String mrl = new File("res/media/video.mp4").getAbsolutePath();

But that of course depends on what is the "current" directory for your application, and won't work inside a jar file.

On the other hand, VLC can play media contained inside zip (and therefore jar) files, with an MRL that looks a little bit like what you posted. Something like:

zip://file.jar!/res/media/video.mp4

本文地址:IT屋 VLCJ - playing a video from the "res" folder works great in eclipse, but not from the executable JAR file

问 题

我有一个.MP4视频放在我的项目中的“res / media”文件夹中。我可以使用这段代码从eclipse中轻松播放这个视频:

  String url = getClass()。getResource “/media/video.mp4”)的GetFile(); 
url = new File(url).getPath();
showMedia(url); //播放视频的方法

我不得不使用这段代码,因为只使用 URL url = getClass()。getResource(“/ media / video.mp4”); 使VLCJ无法使用此URL访问视频。

创建可执行JAR文件时,我在控制台中收到以下出错:

  libdvdnav:使用dvdnav版本5.0 .0 
libdvdread:无法使用libdvdcss打开D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4。
libdvdread:无法打开D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4读
libdvdnav:vm:无法打开/读取DVD
[1644d0ac]文件系统访问错误:无法打开文件D:\Desktop\file:\D:\Desktop\app.jar!\media\video。 mp4(参数无效)
[1644d0ac]主访问错误:文件读取失败
[1644d0ac]主访问错误:VLC无法打开文件“D:\Desktop\file:\D: \Desktop\app.jar!\media\video.mp4“(参数无效)。
[1645643c]主输入错误:打开`file:/// D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4'失败
[1645643c]主输入错误:您的输入无法打开
[1645643c]主输入错误:VLC无法打开MRL文件:/// D:/ Desktop / file%3A / D% 3A /桌面/ app.jar%21 /媒体/ video.mp4' 。检查日志的详细信息。

这些库正在成功读取,我甚至可以播放我的JAR文件外的任何视频。

任何建议?

提前感谢。

解决方案

媒体资源定位器(MRL)与URL不同

您公布的日志显示了VLC正试图开启信息部分是:

  [1644d0ac]文件系统访问错误:无法打开文件D:\Desktop\file:\ D:\Desktop\app.jar!\media\video.mp4(参数无效)

“D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4”显然不是一个有效的文件名?

所以这个代码有缺陷:

哈弗h5经典版视频播放_李宗瑞视频播放手机版下载_视频播放器jar版

  String url = getClass()。getResource(“/ media / video.mp4”)。getFile(); 

这种类型的东西,没有.getFile()通常用于从应用程序加载资源类路径。但是,当您尝试获得文件名时,情况并非如此。

您需要执行以上操作:

  String mrl = new File(“res / media / video.mp4”)。getAbsolutePath(); 

但这当然取决于您的应用程序的“当前”目录,而不会在一个jar文件中工作。

另一方面,VLC 可以播放包含在zip(和显然jar)文件内的外媒视频播放器jar版,并使用MRL看起来有点像你发贴。如下:

  zip://file.jar!/res/media/video.mp4 

本文地址:IT屋 VLCJ - 从“res”播放视频文件夹在eclipse中工作得很高,但不是从可执行文件JAR文件

官方微信

扫一扫关注IT屋

微信公众号搜索 “ IT屋 ” ,选择关注

与百万开发者在一起

官方交流群:IT屋-技术交流群③

Google Facebook Youtube 科学上网》戳这里《

百度翻译此文有道翻译此文

问 题

我有一个.MP4视频放在我的项目中的“res / media”文件夹中。我可以使用这段代码从eclipse中轻松播放这个视频:

  String url = getClass()。getResource “/media/video.mp4”)的GetFile(); 
url = new File(url).getPath();
showMedia(url); //播放视频的方法

我不得不使用这段代码,因为只使用 URL url = getClass()。getResource(“/ media / video.mp4”); 使VLCJ无法使用此URL访问视频。

创建可执行JAR文件时,我在控制台中收到以下出错:

李宗瑞视频播放手机版下载_视频播放器jar版_哈弗h5经典版视频播放

  libdvdnav:使用dvdnav版本5.0 .0 
libdvdread:无法使用libdvdcss打开D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4。
libdvdread:无法打开D:\Desktop\file:\D:\Desktop\app.jar!\media\video.mp4读
libdvdnav:vm:无法打开/读取DVD
[1644d0ac]文件系统访问错误:无法打开文件D:\Desktop\file:\D:\Desktop\app.jar!\media\video。 mp4(参数无效)
[1644d0ac]主访问错误:文件读取失败
[1644d0ac]主访问错误:VLC无法打开文件“D:\Desktop\file:\D: \Desktop\app.jar!\media\video.mp4“(参数无效)。
[1645643c]主输入错误:打开`file:/// D:/Desktop/file%3A/D%3A/Desktop/app.jar%21/media/video.mp4'失败
[1645643c]主输入错误:您的输入无法打开
[1645643c]主输入错误:VLC无法打开MRL文件:/// D:/ Desktop / file%3A / D% 3A /桌面/ app.jar%21 /媒体/ video.mp4' 。检查日志的详细信息。


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/bofangqi/article-120452-1.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    每日福利
    热点图片
    拼命载入中...