VulpesOS/gaia/apps/music/test/marionette/fakecontrols/js/fakecontrols.js
OverSu b38dea0597 Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
2026-09-30 23:13:03 +02:00

38 lines
787 B
JavaScript
Executable file

/* exported controls */
'use strict';
function RemoteControls() {
this.controls = document.getElementById('controls');
this.controls.addEventListener('click', this);
this.playPauseButton = document.getElementById('playpause');
window.navigator.mozSetMessageHandler('connection', function(request) {
if (request.keyword !== 'mediacomms') {
return;
}
this.port = request.port;
}.bind(this));
}
RemoteControls.prototype = {
handleEvent: function(event) {
if (!this.port) {
return;
}
var command = null;
switch (event.target) {
case this.playPauseButton:
command = 'playpause';
break;
}
if (command) {
this.port.postMessage({command: command});
}
}
};
var controls = new RemoteControls();