Skip to content

Instantly share code, notes, and snippets.

@rkorsak
Created January 31, 2018 14:16
Show Gist options
  • Save rkorsak/d9e20de5eb5b9641e0ff24012085d3ef to your computer and use it in GitHub Desktop.
Save rkorsak/d9e20de5eb5b9641e0ff24012085d3ef to your computer and use it in GitHub Desktop.
Tizen web app background audio
<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/BackgroundAudio" version="1.0.0" viewmodes="maximized">
<tizen:application id="59hzphXAzx.BackgroundAudio" package="59hzphXAzx" required_version="3.0"/>
<tizen:background-category value="media"/>
<content src="index.html"/>
<feature name="http://tizen.org/feature/screen.size.all"/>
<icon src="icon.png"/>
<name>BackgroundAudio</name>
<tizen:profile name="mobile"/>
<tizen:setting screen-orientation="portrait" context-menu="enable" background-support="enable" encryption="disable" install-location="auto" hwkey-event="enable"/>
</widget>
window.onload = function() {
// TODO:: Do your initialization job
// add eventListener for tizenhwkey
document.addEventListener('tizenhwkey', function(e) {
if (e.keyName === "back") {
try {
tizen.application.getCurrentApplication().exit();
} catch (ignore) {}
}
});
document.addEventListener('visibilitychange', function() {
console.log('Visibility change! Hidden: ' + document.hidden);
});
var audio = document.createElement('audio');
audio.addEventListener('pause', function() {
console.log('Audio paused!');
});
audio.autoplay = true;
audio.loop = true;
audio.src = './audio.mp3';
function heartbeat() {
console.log('App is still running...');
window.setTimeout(heartbeat, 5000);
}
heartbeat();
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment