1、下載node-webkithtml
下載linux版本的node-webkit,網址以下:https://github.com/rogerwang/node-webkit。文件解壓以後又以下幾個文件,其中nw 就是咱們要執行的命令。node
2、爲火狐安裝VLC插件linux
這裏是使用的linux系統是ubantu,進入命令終端,依次輸入以下命令:git
sudo apt-get update
sudo apt-get install mozilla-plugin-vlc
便可安裝完成。github
3、爲node-webkit安裝vlc插件web
經過文件搜索,查找libvlcplugin.so文件。而後把這個文件複製到已經解壓的node-webkit文件夾裏面,要與nw文件在同一個目錄。json
4、測試例子app
一、新建index.html文件,內容以下:ide
1 <html> 2 <head> 3 <title>Demo</title> 4 </head> 5 <body > 6 <h2>test</h2> 7 <embed type="application/mpeg4-iod" 8 name="video1" 9 autoplay="yes" loop="yes" width="400" height="300" 10 target="/home/user/a.mp4" /> 11 <br /> 12 </body> 13 </html>
其中type:爲視頻的類型,target:爲視頻的完整路徑,autoplay:爲是否自動播放。oop
二、新建package.json文件,內容以下:
1 { 2 "name": "nw-demo", 3 "main": "index.html", 4 "webkit": { 5 "plugin": true 6 } 7 }
其中pulgin:true,表示播放的時候容許使用插件。
三、將這個兩個文件打包命名爲app.nw並存放在node-webkit目錄。 四、經過終端進入node-webkit目錄,也就是nw文件所在的目錄。在終端輸入命令./nw app.nw 視頻便可播放。app.nw表示壓縮文件app.nw的位置。