电子应用程序可以播放本地支持的任何视频吗? [英] Can electron apps play any videos supported locally?

查看:141
本文介绍了电子应用程序可以播放本地支持的任何视频吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道浏览器通常会将播放器限制为 mp4 webm 类型的媒体,但是我想知道基于电子的应用程序是否有可能运行具有MKV和AVI等格式的本地视频.我找不到确切的消息告诉我什么是可用的,什么不可用.

I'm aware that browsers usually restrict players to mp4 and webm type of media, but I'm wondering if it's possible for an electron-based app to run local videos with formats such as MKV and AVI. I can't find a definite source telling me what is and what is not available.

推荐答案

电子仍然仅限于网络技术...

这意味着,即使您可以通过节点API访问文件系统,也无法访问文件,内容呈现仍在 BrowserWindow 内部进行,该浏览器对视频播放的支持与基于Webkit的浏览器大致相同.您可以为此目的使用HTML5视频或画布,这在本机上就差不多了.(理论上也支持Flash,但是运行它所需的工作量在我看来是不值得的……而且,它是 Flash ,所以,不.)

Electron is still limited to web technologies...

This means even though you have access to the file system and whatnot through the node APIs, content rendering happens inside a BrowserWindow which has about the same support for video playback as webkit based browsers. You can use HTML5 video or canvas for this purpose, and that's pretty much it natively. (Flash is theoretically also supported, but the amount of work required to get it running is not worth it in my opinion... also, it's Flash, so, no.)

即使本地支持到此结束,您也可以采取各种方法来解决这些局限性.我将列出一些最常见的:

Even though native support ends there, you have various paths you can take to work around these limitaions. I'll list a few of the most common ones:

  • 在后台将您的MKV/AVI视频转换为支持的格式之一.这样做的缺点是需要将整个视频文件显示在文件系统上(即不适用于流).
  • 即时将您的MKV/AVI流转码为支持的格式.这非常灵活,但是对您的环境有一些严格的要求,例如在本地安装ffmpeg(或类似的东西).祝您好运,如果您想分发自己的应用,请打包.
  • 使播放器能够播放MKV/AVI.最常见的示例是通过将节点绑定到 libvlc 来嵌入VLC Player.查看 wcjs-player & wcjs-prebuilt 模块,如果您要采用这种方式,则它们是webchimera.js视频播放器的节点包装,该视频播放器在后台使用VLC.(我不隶属于他们,只是目前在我的其中一个项目中,这些模块已经用于类似的事情,到目前为止都取得了成功.)
  • Convert your MKV/AVI video in the background to one of the supported formats. This has the drawback of needing the entire video file to be present on your filesystem (i.e doesn't work for streams).
  • Transcode your MKV/AVI stream on the fly to a supported format. This is pretty flexible but has some serious requirements on your environment, like having ffmpeg (or something similar) installed locally. Good luck packaging that if you want to distribute your app.
  • Embed a player capable of MKV/AVI playback. Most common example is VLC Player embedded through node bindings to libvlc. Check out the wcjs-player & wcjs-prebuilt modules if you want to go this way, they are node wrappers for the webchimera.js video player, which uses VLC in the background. (I'm not affiliated with them, just currently using the modules for something similar in one of my projects with success so far.)

我敢肯定还有其他解决方案,但是这些是我在研究该主题时发现的最合逻辑的解决方案.希望这会有所帮助!

I'm sure there are other solutions to this, but these are the most logical ones I've found while researching on the subject. Hope this helps!

这篇关于电子应用程序可以播放本地支持的任何视频吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆