I am trying to play youtube video from chrome extension's background script as below, but it does not seem to work:
chrome.tabs.executeScript(tabId,{code:"var player = document.getElementById('movie_player'); if(player.getPlayerState()!=1){player.playVideo();}" } );
Related
How can I play a specific Youtube Video on my Google Hub via Google Actions? I know I can use a Basic Card to display images and text and even a link (although that link does not show up on the HUB)
I specifically want to be able to trigger or to play a youtube video on my Google Hub.
Actions are not able to start playing video content. Media responses are only for audio.
I have a similar need. After a chat with an action on google, I want to play user requested youtube videos (chains-of) on a local "big screen" (TV-like / PC).
A workaround solution could be:
you realize an action that select one or more videos.
The action act also as a server for a client described here below
The action communicate (SSE, websocket, HTTP...) with a client browser page containing a javascript small program that dynamically visualize the video (id sent via SSE client-server communication)
Here below the rough js script (I'm not a web developer); that just gives you the idea:
<script language="javascript">
function loadVideoWithId(id) {
const tvEmbedMode = "embed/" //"tv#/watch?v="
const url = `https://www.youtube.com/embed/${id}?fs=1&autoplay=1&loop=1` //
const iframe = `<iframe src="${url}" width="1600" height="900" allowFullScreen="allowFullScreen" frameBorder="0" />`
document.write(iframe)
}
loadVideoWithId('hHW1oY26kxQ')
</script>
I have a Chrome extension, which detects Youtube videos and gets their category via the Youtube API as follows:
background.js
chrome.webRequest.onBeforeRequest.addListener(function(details) {
var PageInfo = new URL(url);
if(PageInfo.host=="www.youtube.com")
getCategory(PageInfo); //returns category number via the Youtube API
});
The problem I'm facing is that this does not work if Youtube is in full screen mode. For example after I load a video normally, I change to full screen and pick a video from the suggested videos after the initial one has finished playing. I then cannot get the extension to correctly pick up that new video.
Any tips would be appreciated. Thanks.
I am trying my hand at developing my own Safari extensions that could perform basic Pandora commands from the an extension menu (with an open tab streaming from the Pandora site). I'm just wondering if there is a way I can programmatically mute my Pandora music if I were to play a YouTube video from another tab? I've seen it done on a Google Chrome extension called "SoundControl" but have no idea whether it is at all possible to implement on Safari. Any suggestions or reference to the safari manual would be appreciated. Thanks!
Add an event listener to your code like this:
safari.application.addEventListener("activate", activateHandler, true);
function activateHandler(event) {
if(event.target.activeTab.url.indexOf("youtube") != -1)
{
//Pause your player in here
}
}
Look at music player tutorial in here
Window or tab activated event tutorial is in here
So here is what I am trying to do:
The app in question that this problem is regarding is here: https://github.com/viperfx/ng-juketube, to give everyone some context. So I am loading a youtube video in the background using the youtube Iframe API giving it a youtube video id. That works well. Next, I want to find out the playlist ID of the youtube mix's that appear sometimes on the sidebar.
Current solution:
I am using nodejs in the backend to scrape the youtube video page, and then look in the sidebar for the string 'Youtube Mix'. When I am running my server locally this works well. However when I am running the app from heroku I do not get the same results (as in a mix does not show up) because I am assuming the youtube server and the IP address I have are affecting youtube mix from showing up.
So my question is how can I obtain the youtube mix playlist id using the client (browser) rather than the server?
I have tried things like trying to load the youtube page as an iframe - does not work. iframes only allowed for /embed*
So here is how I solved this issue.
Using a service called http://www.corsproxy.com/ I was able to scrape youtube and get the playlist id using client side code. Here is a snippet from my code showing the solution:
$.get('http://www.corsproxy.com/www.youtube.com/watch?v='+newVal.videoId,function(response) {
var doc = new DOMParser().parseFromString(response, 'text/html');
$scope.mixId = doc.querySelector('.related-playlist').getAttribute('href').split('list=')[1];
$scope.$apply();
});
I am working on a metro app. I have to play youtube video in its embeded player not in that provided by metro app.
I search in net and find that there is iframe, flash and object player .I tried to implement in my app but not succeed.
Is there any to play video or I have to use the default metro player to play?
Have a look at How to play YouTube videos in a Windows8 html/javascript app?
You can add a youtube embed code in a webview element.
XAML design
place a webview element
XAML.cs add this code below the this.InitializeComponent();
string htmContent = " html text here";
webview.NavigateToString(htmContent);
Check out the YouTube class from the MyToolkit. You give it a video ID (the last part of the URL) and it gets a MP4 file from Youtube for you that you can play using the standard MediaElement.