mirror of
https://github.com/KevinMidboe/zoff.git
synced 2025-10-29 18:00:23 +00:00
Use best connection to chromecast
This commit is contained in:
@@ -435,6 +435,13 @@ function setup_no_connection_listener(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updateChromecastMetadata() {
|
||||||
|
if(!chromecastAvailable) return;
|
||||||
|
var image = 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg';
|
||||||
|
if(Player.np.thumbnail) image = Player.np.thumbnail;
|
||||||
|
chrome.cast.media.GenericMediaMetadata({metadataType: 0, title:Player.np.title, image: image, images: [image]});
|
||||||
|
}
|
||||||
|
|
||||||
function setup_now_playing_listener(){
|
function setup_now_playing_listener(){
|
||||||
socket.on("np", Player.now_playing_listener);
|
socket.on("np", Player.now_playing_listener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ 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.me", chromecastListener)
|
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener)
|
||||||
chrome.cast.media.GenericMediaMetadata({metadataType: 0, title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg', images: ['https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg']});
|
updateChromecastMetadata();
|
||||||
//chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
//chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||||
chromecastAvailable = true;
|
chromecastAvailable = true;
|
||||||
paused = false;
|
paused = false;
|
||||||
@@ -296,9 +296,9 @@ initializeCastApi = function() {
|
|||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
||||||
|
|
||||||
if(Helper.mobilecheck()) {
|
//if(Helper.mobilecheck()) {
|
||||||
socket.emit("get_id");
|
socket.emit("get_id");
|
||||||
}
|
//}
|
||||||
hide_native(1);
|
hide_native(1);
|
||||||
if(Helper.mobilecheck()) {
|
if(Helper.mobilecheck()) {
|
||||||
Player.playVideo();
|
Player.playVideo();
|
||||||
@@ -311,7 +311,7 @@ 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.me", chromecastListener);
|
castSession.addMessageListener("urn:x-cast:zoff.me", chromecastListener);
|
||||||
chrome.cast.media.GenericMediaMetadata({metadataType: 0, title:song_title, image: 'https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg', images: ['https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg']});
|
updateChromecastMetadata();
|
||||||
//chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
//chrome.cast.Image('https://img.youtube.com/vi/'+video_id+'/mqdefault.jpg');
|
||||||
chromecastAvailable = true;
|
chromecastAvailable = true;
|
||||||
paused = false;
|
paused = false;
|
||||||
@@ -322,9 +322,9 @@ initializeCastApi = function() {
|
|||||||
} catch(event){
|
} catch(event){
|
||||||
_seekTo = seekTo;
|
_seekTo = seekTo;
|
||||||
}
|
}
|
||||||
if(Helper.mobilecheck()) {
|
//if(Helper.mobilecheck()) {
|
||||||
socket.emit("get_id");
|
socket.emit("get_id");
|
||||||
}
|
//}
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "loadVideo", start: Player.np.start, end: Player.np.end, videoId: video_id, seekTo: _seekTo, channel: chan.toLowerCase(), source: videoSource, thumbnail: Player.np.thumbnail})
|
||||||
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
castSession.sendMessage("urn:x-cast:zoff.me", {type: "nextVideo", videoId: full_playlist[0].id, title: full_playlist[0].title, source: full_playlist[0].source, thumbnail: full_playlist[0].thumbnail})
|
||||||
hide_native(1);
|
hide_native(1);
|
||||||
|
|||||||
@@ -85,6 +85,7 @@ var Player = {
|
|||||||
Player.cueVideoById(Player.np.id, duration, Player.np.start, Player.np.end);
|
Player.cueVideoById(Player.np.id, duration, Player.np.start, Player.np.end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
updateChromecastMetadata();
|
||||||
},
|
},
|
||||||
|
|
||||||
setThumbnail: function(conf, video_id) {
|
setThumbnail: function(conf, video_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user