forked from ghouet/chrome-hls
-
Notifications
You must be signed in to change notification settings - Fork 1
/
player.js
48 lines (43 loc) · 1.19 KB
/
player.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var flv;
// var hls;
var debug;
function playFLV(url){
var video = document.getElementById('video');
if(native){
video.classList.add("native_mode");
video.classList.remove("zoomed_mode");
} else {
video.classList.remove("native_mode");
video.classList.add("zoomed_mode");
}
if(flv){ flv.destroy(); }
var flvUrl = decodeURIComponent(url)
flv = flvjs.createPlayer({
type: 'flv',
url: flvUrl
})
console.log(flv, typeof flv)
flv.attachMediaElement(video)
flv.load()
flv.play()
document.title = url
}
chrome.storage.local.get({
flvjs: currentVersion,
debug: false,
native: false
}, function(settings) {
debug = settings.debug;
native = settings.native;
var s = document.createElement('script');
var version = currentVersion
if (supportedVersions.includes(settings.flvjs)) {
version = settings.flvjs
}
s.src = chrome.runtime.getURL('flvjs/flv.'+version+'.min.js');
s.onload = function() { playFLV(window.location.href.split("#")[1]); };
(document.head || document.documentElement).appendChild(s);
});
$(window).bind('hashchange', function() {
playFLV(window.location.href.split("#")[1]);
});