@@ -4,7 +4,7 @@ import html from 'nanohtml' | |||||
import { parseMediaFragmentIdentifier } from '../util/media-fragment-identifier.js'; | import { parseMediaFragmentIdentifier } from '../util/media-fragment-identifier.js'; | ||||
async function init() { | |||||
export default async function init() { | |||||
document.body.innerHTML = ''; | document.body.innerHTML = ''; | ||||
const mainEl = html` | const mainEl = html` | ||||
@@ -88,8 +88,3 @@ async function init() { | |||||
return playlist; | return playlist; | ||||
} | } | ||||
init().then(playlist => { | |||||
// Store playlist as a shared global variable. | |||||
self.playlist = playlist; | |||||
}); |
@@ -27,7 +27,7 @@ function describeMediaFragment({ start, end }) { | |||||
return selector; | return selector; | ||||
} | } | ||||
async function init() { | |||||
export default async function init(playlist) { | |||||
let menuEl; | let menuEl; | ||||
function hideMenu() { | function hideMenu() { | ||||
@@ -41,10 +41,6 @@ async function init() { | |||||
const left = event.pageX; | const left = event.pageX; | ||||
const top = event.pageY; | const top = event.pageY; | ||||
const playlist = self.playlist; | |||||
if (!playlist) { | |||||
throw new Error('Player has not been initialised.'); | |||||
} | |||||
const trackDuration = playlist.duration; | const trackDuration = playlist.duration; | ||||
let { start, end } = playlist.getTimeSelection(); | let { start, end } = playlist.getTimeSelection(); | ||||
if (start === undefined) return; | if (start === undefined) return; | ||||
@@ -84,5 +80,3 @@ async function init() { | |||||
document.addEventListener('click', event => { hideMenu(); }); | document.addEventListener('click', event => { hideMenu(); }); | ||||
} | } | ||||
init(); |
@@ -1,2 +1,9 @@ | |||||
import '../audio-player/contentscript.js' | |||||
import '../create-bookmarks/contentscript.js' | |||||
import initAudioPlayer from '../audio-player/contentscript.js'; | |||||
import initCreateBookmarks from '../create-bookmarks/contentscript.js'; | |||||
async function init() { | |||||
const playlist = await initAudioPlayer(); | |||||
await initCreateBookmarks(playlist); | |||||
} | |||||
init(); |