HOWTO: Web video with omxplayerGUI and Chromium-Browser - Raspberry Pi Forums


for more 3 years kweb(3) has built-in possibility play web video (youtube , 600+ other websites) in high resolution , perfect quality using omxplayer(gui). click "play" button in toolbar on video web page.

kusti8 has published extension chromium-browser offers same functionality. uses kweb package (omxplayergui , youtube-dl-server). unfortunately doesn't work more recent rpf chromium-browser version.

have built similar solution firefox, can used chromium-browser (although less elegant kusti8's solution).

installation

1) need kweb package, if don't have installed already: viewtopic.php?t=40860
during installation asked, if want install github version of youtube-dl. it's important answer "y". if missed that, can install later kweb's application page.

simple method:
(based on solution firefox suggested martinlaclaustra):

in chromium right click bookmarks toolbar , select "add page". in form set name "playvideo" , paste following url field:

code: select all

javascript:(function(){var target_url=window.location.href;var ytsvr="http://localhost:9192/play?url=";var final=ytsvr.concat(encodeuricomponent(target_url));var mywindow=window.open(final,'_top')})();
select "bookmarks toolbar" below , click "save". should have new button "playvideo".

that's all. can skip steps 2) , 3) below.

userscript method:

2) start chromium-browser , select "settings" menu. select "extensions". @ bottom there link "download more extensions" (or similar, i'm on german system). click it. new tab open chrome web store. search "tapermonkey" , install it. restart chromium-browser afterwards.

3) go extensions again, find tapermonkey extension , click on "options". on tapermonkeys menu bar click icon on left (it's one, other menu items displayed text). script editor open "new script" heading. remove default content , paste following editor:

code: select all

// ==userscript== // @name        omxvideo // @namespace   http://steinerdatenbank.de // @description play web video omxplayergui // @include     * // @version     1 // @grant       gm_registermenucommand // @grant       gm_getvalue // @grant       gm_setvalue // ==/userscript==  gm_registermenucommand( "play video", playvideo, "p"); gm_registermenucommand("video button on/off",togglebutton);  if (gm_getvalue('playbutton',false) === true) { var input=document.createelement("input"); input.type="button"; input.value="play"; input.onclick = playvideo; input.setattribute("style", "font-size:10px;position:absolute;top:100px;right:20px;");   document.body.appendchild(input); }  function playvideo() {   var newuri = "http://localhost:9192/play?url=" + window.location.href;   window.top.location.href = newuri; }  function togglebutton() { if (gm_getvalue('playbutton',false) === false) { gm_setvalue('playbutton',true) ; } else { gm_setvalue('playbutton',false); } }
click "save" icon (second left). if browse web page, tapermonkey icon display content shown in attached image.
chromiumytdl.jpg
chromiumytdl.jpg (30.42 kib) viewed 4448 times
contains 2 new commands: "play video" , "video button on/off". in order use them, youtube-dl-server of kweb package must running (see below).

4) step optional, easiest way use chromium-browser new feature.
open terminal create script:

code: select all

cd desktop nano chromium-omx
enter following (you can use right click , "paste"):
#!/bin/bash
ytdl_server.py > /dev/null 2>&1 &
chromium-browser
wget -o /dev/null http://localhost:9192/stop
press ctrl+o save , ctrl+x leave editor.
have make script executable:

code: select all

chmod +x  chromium-omx
script start youtube-dl-server (running in background), chromium-browser , stop youtube-dl-server again, if quit chromium.

usage

note: in order use extension, youtube-dl-server must running. there different ways this:
1) use script created in step 4 above start chromium-browser server. stop server cleanly when close browser.
2) if have started chromium-browser application menu, can start server separately in 2 ways:
open terminal , enter:
ytdl_server.py
( clicking "start server" frome kweb's applications page same)

alternatively can start omxplayergui frontend application menu. start server (and stop it, if close omxplayergui frontend).

go video page on youtube (or other supported website). if using simple method, click "playvideo" in bookmarks toolbar. if using userscript method, select "play video" tapermonkey menu. after few seconds (2-3 on rpi 3, may take little bit longer first video) omxplayergui opened , start playing video. video in web page stop playing, because shows simple web page youtube-dl-server message "playing: " followed title of video , "go back" button below. click button return original video web page after have finished watching video.

second user script command "video button on/off" gives faster way start playing video. if click , reload page, small "play" button appear on top right side of (almost) every web page. clicking "play" button start video player in same way using menu command. disable button again, select user script command "video button on/off" again (it's toggle command).

note: on websites (vimeo.com, example) "play" button may not visible, because hidden else. in case have use menu command.

note 2: "play" button appear within frames or iframes contained in page. may irritating, has 1 advantage: if web page uses embedded video, "play" button inside embedding frame can used start playing video. example embedded videos in raspberry pi blog. clicking "play" button on top of page not start video, clicking "play" button inside video frame work.

stopping youtube-dl server
if have started chromium-browser script created in step 4 above, don't have anything. if have started manually can close terminal window. or can stop inisde chromium-browser:
go "http://localhost:9192/stop" (add bookmark!).

using , configuring omxplayergui
if new omxplayergui should start frontend , click "help" button. open omxplayergui manual in preferred pdf viewer. give information need using , configuring omxplayergui. there lot of fine tuning options.

updating youtube-dl
should update youtube-dl time time. not use "youtube-dl -u" command! can in 2 ways:
1) start terminal , run
update-ytdl
(no sudo!)
2) start kweb, click on "applications". @ bottom ("youtube-dl tools") click button "update (git)".

note: if kusti8's extension working again, should prefer it. starts , stops youtube-dl-server automatically you.

works treat! thanks.


raspberrypi



Comments