Updated chromecast sender

- Trying to get YouTube thumbnail to show up in the notificationbar
 - Trying to get YouTube title to show up in the notificationbar
This commit is contained in:
Kasper Rynning-Tønnesen
2017-01-24 11:54:12 +01:00
parent 8561b715e4
commit e515915ec8
4 changed files with 14 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -272,6 +272,8 @@ initializeCastApi = function() {
case cast.framework.SessionState.SESSION_STARTED: case cast.framework.SessionState.SESSION_STARTED:
castSession = cast.framework.CastContext.getInstance().getCurrentSession(); castSession = cast.framework.CastContext.getInstance().getCurrentSession();
castSession.addMessageListener("urn:x-cast:zoff.no", chromecastListener) castSession.addMessageListener("urn:x-cast:zoff.no", chromecastListener)
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'});
chrome.cast.Image('https://img.youtube.com/vi/'+id+'/mqdefault.jpg');
chromecastAvailable = true; chromecastAvailable = true;
paused = false; paused = false;
mobile_beginning = false; mobile_beginning = false;
@@ -288,6 +290,8 @@ initializeCastApi = function() {
case cast.framework.SessionState.SESSION_RESUMED: case cast.framework.SessionState.SESSION_RESUMED:
castSession = cast.framework.CastContext.getInstance().getCurrentSession(); castSession = cast.framework.CastContext.getInstance().getCurrentSession();
castSession.addMessageListener("urn:x-cast:zoff.no", chromecastListener); castSession.addMessageListener("urn:x-cast:zoff.no", chromecastListener);
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'});
chrome.cast.Image('https://img.youtube.com/vi/'+id+'/mqdefault.jpg');
chromecastAvailable = true; chromecastAvailable = true;
paused = false; paused = false;
mobile_beginning = false; mobile_beginning = false;

View File

@@ -174,6 +174,8 @@ var Player = {
if(chromecastAvailable){ if(chromecastAvailable){
castSession.sendMessage("urn:x-cast:zoff.no", {type: "playVideo"}); castSession.sendMessage("urn:x-cast:zoff.no", {type: "playVideo"});
//socket.emit('pos', {channel: chan.toLowerCase()}); //socket.emit('pos', {channel: chan.toLowerCase()});
chrome.cast.media.GenericMediaMetadata({title:song_title, image: 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'});
chrome.cast.Image('https://img.youtube.com/vi/'+id+'/mqdefault.jpg');
if($("#pause").hasClass("hide")){ if($("#pause").hasClass("hide")){
$("#play").toggleClass("hide"); $("#play").toggleClass("hide");
$("#pause").toggleClass("hide"); $("#pause").toggleClass("hide");
@@ -208,6 +210,8 @@ var Player = {
loadVideoById: function(id){ loadVideoById: function(id){
if(chromecastAvailable){ if(chromecastAvailable){
castSession.sendMessage("urn:x-cast:zoff.no", {type: "loadVideo", videoId: id}); castSession.sendMessage("urn:x-cast:zoff.no", {type: "loadVideo", videoId: id});
chrome.cast.media.GenericMediaMetadata({metadataType: "GENERIC", title:song_title, image: 'https://img.youtube.com/vi/'+id+'/mqdefault.jpg'});
chrome.cast.Image('https://img.youtube.com/vi/'+id+'/mqdefault.jpg');
} else { } else {
Player.player.loadVideoById(id); Player.player.loadVideoById(id);
} }