Recently kusti8 has published an extension for the Chromium-Browser that offers the same functionality. It also uses the kweb package (omxplayerGUI and youtube-dl-server). Unfortunately this doesn't work any more with the recent RPF chromium-browser version.
I have built a similar solution for Firefox, which can also be used for chromium-browser now (although it is less elegant than kusti8's solution).
Installation
1) You need the kweb package, if you don't have it installed already: viewtopic.php?t=40860
During installation you will be asked, if you want to install the github version of youtube-dl. It's important to answer with "y". If you missed that, you can install it later from kweb's application page.
Simple method:
(based on a solution for Firefox suggested by MartinLaclaustra):
In chromium right click into the bookmarks toolbar and select "Add Page". In the form set name to "PlayVideo" and paste the following into the 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')})();
That's all. You can skip steps 2) and 3) below.
Userscript method:
2) Start chromium-browser and select "Settings" from the menu. Select "Extensions". At the bottom there is a link "Download more extensions" (or similar, I'm on a German system). Click it. A new tab will open with the chrome web store. Search for "Tapermonkey" and install it. Restart chromium-browser afterwards.
3) Go to extensions again, find the tapermonkey extension and click on "Options". On Tapermonkeys menu bar click the icon on the left (it's the only one, the other menu items are displayed as text). The script editor will open with the "New Script" heading. Remove the default content and paste the following into the editor:
Code: Select all
// ==UserScript==
// @name omxVideo
// @namespace http://steinerdatenbank.de
// @description Play web video with 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); }
}
4) This step is optional, but it is the easiest way to use Chromium-Browser with the new feature.
Open a terminal to create a script:
Code: Select all
cd Desktop
nano chromium-omx
Press CTRL+o to save it and CTRL+x to leave the editor.#!/bin/bash
ytdl_server.py > /dev/null 2>&1 &
chromium-browser
wget -O /dev/null http://localhost:9192/stop
We have to make the script executable:
Code: Select all
chmod +x chromium-omx
Usage
Note: In order to use the extension, the youtube-dl-server must be running. There are different ways to do this:
1) Use the script created in step 4 above to start chromium-browser together with the server. This will also stop the server cleanly when you close the browser.
2) If you have started chromium-browser from the application menu, you can start the server separately in two ways:
Open a terminal and enter:
ytdl_server.py
( Clicking "Start Server" frome kweb's applications page will do the same)
Alternatively you can also start the omxplayerGUI frontend from the application menu. This will also start the server (and stop it, if you close omxplayerGUI frontend).
Now go to a video page on youtube (or any other supported website). If you are using the simple method, click "PlayVideo" in the bookmarks toolbar. If you are using the userscript method, select "Play Video" from the Tapermonkey menu. After a few seconds (2-3 on a RPi 3, but it may take a little bit longer for the first video) omxplayerGUI will be opened and start playing the video. The video in the web page will stop playing, because now it shows a very simple web page from the youtube-dl-server with a message "Playing: " followed by the title of the video and a "Go Back" button below. Click this button to return to the original video web page after you have finished watching the video.
The second user script command "Video Button on/off" gives you a faster way to start playing a video. If you click it and reload the page, a small "Play" button will appear on the top right side of (almost) every web page. Clicking this "Play" button will start the video player in the same way as using the menu command. To disable the button again, select the user script command "Video Button on/off" again (it's a toggle command).
Note: On some websites (vimeo.com, for example) the "Play" button may not be visible, because it is hidden by something else. In this case you have to use the menu command.
Note 2: The "Play" button will also appear within frames or iframes contained in a page. This may be irritating, but also has one advantage: if a web page uses an embedded video, the "Play" button inside the embedding frame can be used to start playing the video. A good example are the embedded videos in the Raspberry Pi Blog. Clicking the "Play" button on top of the page will not start any video, but clicking the "Play" button inside the video frame will work.
Stopping the youtube-dl server
If you have started chromium-browser with the script created in step 4 above, you don't have to do anything. If you have started it manually you can simply close the terminal window. Or you can stop it from inisde chromium-browser:
go to "http://localhost:9192/stop" (add this as a bookmark!).
Using and Configuring omxplayerGUI
If you are new to omxplayerGUI you should start the frontend and click the "Help" button. This will open the omxplayerGUI manual in your preferred PDF viewer. It will give you all the information you need about using and configuring omxplayerGUI. There are really a lot of fine tuning options.
Updating youtube-dl
You should update youtube-dl from time to time. Do not use the "youtube-dl -U" command! You can do it in two ways:
1) Start a terminal and run
update-ytdl
(no sudo!)
2) Start kweb, click on "Applications". At the bottom ("Youtube-dl Tools") click the button "Update (git)".
Note: If kusti8's extension will be working again, you should prefer it. It starts and stops the youtube-dl-server automatically for you.