Opening for better integration with fetching and sending title-events

This commit is contained in:
Kasper Rynning-Tønnesen
2017-06-03 21:14:18 +02:00
parent 57b1b68fb3
commit 5500e89579
4 changed files with 14 additions and 3 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

@@ -18,6 +18,11 @@
<script>
function receiveMessage(event)
{
if(event.data == "parent") {
//console.log(event);
window.parentWindow = event.source;
window.parentOrigin = event.origin;
}
if(event.data == "lower") {
window.setVolume(10);
}else if(event.data == "reset") {

View File

@@ -77,6 +77,12 @@ var Player = {
song_title = obj.np[0].title;
duration = obj.np[0].duration;
if(embed) {
if(window.parentWindow && window.parentOrigin) {
window.parentWindow.postMessage({type: "np", title: obj.np[0].title}, window.parentOrigin);
}
}
if(mobile_beginning && Helper.mobilecheck() && seekTo === 0 && !chromecastAvailable) {
seekTo = 1;
}
@@ -411,7 +417,7 @@ var Player = {
notifyUser: function(id, title) {
title = title.replace(/\\\'/g, "'").replace(/&quot;/g,"'").replace(/&amp;/g,"&");
if (Notification.permission === "granted" && document.hidden) {
if (Notification.permission === "granted" && document.hidden && !embed) {
var notification = new Notification("Now Playing", {body: title, icon: "https://i.ytimg.com/vi/"+id+"/mqdefault.jpg", iconUrl: "http://i.ytimg.com/vi/"+id+"/mqdefault.jpg"});
notification.onclick = function(x) { window.focus(); this.cancel(); };
setTimeout(function(){