mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
100 lines
2.5 KiB
HTML
100 lines
2.5 KiB
HTML
<!DOCTYPE HTML>
|
|
<html>
|
|
<head>
|
|
<title>Test audio-channel-changed & visible-audio-channel-changed mozChromeEvent</title>
|
|
</head>
|
|
<body>
|
|
<div id="content"></div>
|
|
<script>
|
|
var normalAudio;
|
|
var contentAudio;
|
|
var notificationAudio;
|
|
var alarmAudio;
|
|
var telephonyAudio;
|
|
var ringerAudio;
|
|
var publicnotificationAudio;
|
|
|
|
function playWithAudioType(audio, type) {
|
|
audio.mozAudioChannelType = type;
|
|
audio.src = "test.ogg";
|
|
audio.loop = true;
|
|
|
|
audio.play();
|
|
}
|
|
|
|
function runTest() {
|
|
// normal channel.
|
|
normalAudio = new Audio();
|
|
playWithAudioType(normalAudio, 'normal');
|
|
|
|
// content channel.
|
|
contentAudio = new Audio();
|
|
playWithAudioType(contentAudio, 'content');
|
|
|
|
// notification channel.
|
|
notificationAudio = new Audio();
|
|
playWithAudioType(notificationAudio, 'notification');
|
|
|
|
// alarm channel.
|
|
alarmAudio = new Audio();
|
|
playWithAudioType(alarmAudio, 'alarm');
|
|
|
|
// telephony channel.
|
|
telephonyAudio = new Audio();
|
|
playWithAudioType(telephonyAudio, 'telephony');
|
|
|
|
// ringer channel.
|
|
ringerAudio = new Audio();
|
|
playWithAudioType(ringerAudio, 'ringer');
|
|
|
|
// publicnotification channel.
|
|
publicnotificationAudio = new Audio();
|
|
playWithAudioType(publicnotificationAudio, 'publicnotification');
|
|
|
|
window.addEventListener('hashchange', function(event) {
|
|
if (location.hash == "#pauseAudio") {
|
|
publicnotificationAudio.pause();
|
|
ringerAudio.pause();
|
|
telephonyAudio.pause();
|
|
}
|
|
|
|
if (location.hash == "#pauseAudioFollowing") {
|
|
alarmAudio.pause();
|
|
notificationAudio.pause();
|
|
contentAudio.pause();
|
|
normalAudio.pause();
|
|
}
|
|
}, false);
|
|
}
|
|
|
|
function checkBackgroundStatus() {
|
|
if (location.hash == "#fg") {
|
|
runTest();
|
|
return;
|
|
}
|
|
|
|
if (document.hidden) {
|
|
runTest();
|
|
return;
|
|
}
|
|
|
|
document.addEventListener('visibilitychange', function visibilityChange() {
|
|
if (document.hidden) {
|
|
runTest();
|
|
}
|
|
});
|
|
}
|
|
|
|
SpecialPowers.pushPermissions(
|
|
[{ "type": "audio-channel-content", "allow": 1, "context": document },
|
|
{ "type": "audio-channel-notification", "allow": 1, "context": document },
|
|
{ "type": "audio-channel-alarm", "allow": 1, "context": document },
|
|
{ "type": "audio-channel-telephony", "allow": 1, "context": document },
|
|
{ "type": "audio-channel-ringer", "allow": 1, "context": document },
|
|
{ "type": "audio-channel-publicnotification", "allow": 1, "context": document }],
|
|
checkBackgroundStatus);
|
|
|
|
</script>
|
|
</body>
|
|
</html>
|