Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
# jwplayer-hlsjs
hls.js provider for jwplayer

## Build instructions

```
npm install
npm run build
```

Then you can find JS library in `dist` directory.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,18 @@
]
},
"dependencies": {
"eventemitter3": "^2.0.2"
"eventemitter3": "^4.0.0"
},
"devDependencies": {
"browserify-derequire": "^0.9.4",
"browserify-derequire": "^1.0.1",
"browserify-versionify": "^1.0.6",
"grunt": "^1.0.1",
"grunt-browserify": "^5.0.0",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-jshint": "^1.1.0",
"grunt-contrib-uglify": "^2.0.0",
"grunt-contrib-clean": "^2.0.0",
"grunt-contrib-jshint": "^2.1.0",
"grunt-contrib-uglify": "^4.0.1",
"grunt-exorcise": "^2.1.1",
"load-grunt-tasks": "^3.5.2",
"load-grunt-tasks": "^5.1.0",
"npm-run-all": "^4.0.1"
}
}
34 changes: 17 additions & 17 deletions src/jwplayer.hlsjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var jwe = {

// XXX arik: protect against exceptions in api. currently jwplayer will be
// stuck + add test
function HlsProv(id){
function HlsProv(id, _playerConfig, mediaElement){
var jwplayer = E.jwplayer||window.jwplayer, Hls = E.Hls||window.Hls;
var jw = id && jwplayer(id);
console.log('init hola/hls provider v'+E.VERSION+' hls v'+Hls.version+
Expand Down Expand Up @@ -201,8 +201,12 @@ function HlsProv(id){
|| / (Chrome|Version)\/\d+(\.\d+)+.* Safari\/\d+(\.\d+)+/.test(ua)
|| /Firefox\/(\d+(?:\.\d+)+)/.test(ua);
};
var element = document.getElementById(id), container;
var video = element ? element.querySelector('video') : undefined, hls;
var video = mediaElement;
if (!video) {
var element = document.getElementById(id);
video = element ? element.querySelector('video') : undefined;
}
var hls, container;
var try_play, can_play, _is_mobile = this.is_mobile();
var visual_quality = {reason: 'initial choice', mode: 'auto'};
if (!video)
Expand All @@ -211,6 +215,7 @@ function HlsProv(id){
if (_is_mobile)
video.setAttribute('jw-gesture-required', '');
}
this.video = video;
video.className = 'jw-video jw-reset';
// XXX marka: mark html5 element to skip autodetection of dm/hls
video.hola_dm_hls_attached = true;
Expand Down Expand Up @@ -326,6 +331,8 @@ function HlsProv(id){
// XXX pavelki: add checking of playlist
if (video.textTracks.length)
video.textTracks.onaddtrack();
_this.trigger(jwe.JWPLAYER_MEDIA_TYPE, {mediaType: video.videoHeight ?
'video' : 'audio'});
},
loadedmetadata: function(){
if (video.muted)
Expand Down Expand Up @@ -461,17 +468,8 @@ function HlsProv(id){
currentQuality: get_level().jw,
levels: get_levels()
});
var levels, is_video = 0;
if (!(levels = hls.levels))
return;
levels.forEach(function(level){
is_video += +!!(level.videoCodec || !level.audioCodec &&
(level.bitrate>64000 || level.width || level.height));
});
_this.trigger(jwe.JWPLAYER_MEDIA_TYPE, {mediaType: is_video ?
'video' : 'audio'});
});
hls.on(Hls.Events.LEVEL_SWITCH, function(e, data){
hls.on(Hls.Events.LEVEL_SWITCHED, function(e, data){
var levels = get_levels(), level_id = get_level(data.level);
_this.trigger(jwe.JWPLAYER_MEDIA_LEVEL_CHANGED, {
currentQuality: level_id.jw,
Expand Down Expand Up @@ -553,7 +551,6 @@ function HlsProv(id){
// eg. http://www.ozee.com/shows/muddha-mandaram#hola_mode=cdn&hola_zone=ozee_hap
this.resize = function(width, height, stretching){};
this.remove = function(){
this.in_container = false;
hls.stopLoad();
this.source = undefined;
if (container === video.parentNode)
Expand All @@ -573,8 +570,9 @@ function HlsProv(id){
this.getContainer = function(){ return container; };
this.setContainer = function(element){
container = element;
container.appendChild(video);
this.in_container = true;
if (this.video.parentNode !== element) {
container.appendChild(video);
}
};
hls.manual_level = -1;
this.setCurrentQuality = function(level){
Expand Down Expand Up @@ -613,7 +611,9 @@ function HlsProv(id){
this.level_cb = undefined;
}
// XXX pavelki: hack to remove pending segments
delete hls.bufferController.segments;
if (hls.bufferController !== undefined) {
delete hls.bufferController.segments;
}
this.attached = false;
return video;
};
Expand Down