-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.js
34 lines (27 loc) · 928 Bytes
/
start.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(function() {
if(window !== window.top)
return;
console.log('sendToXBMC started');
var handle_message = function(msgEvent) {
var messageName = msgEvent.name;
var messageData = msgEvent.message;
console.log('inject message: ' + messageName);
if(messageName === 'stop Player'){
if(document.getElementById('CTPmediaElement0') !== null){
document.getElementById('CTPmediaElement0').pause();
console.log('player: html5');
}
else if(document.getElementById('movie_player') !== null){
document.getElementById('movie_player').stopVideo();
console.log('player: flash');
}
}
};
var handle_keypress = function(e) {
console.log('handing ' + e.keyCode);
if(e.keyCode !== 223) return;
safari.self.tab.dispatchMessage("keyboard", window.location.href);
}
safari.self.addEventListener("message", handle_message, false);
window.addEventListener("keypress", handle_keypress)
})();