Skip to content

Commit

Permalink
quality update event for dynamic streams
Browse files Browse the repository at this point in the history
  • Loading branch information
frankyghost committed Oct 22, 2013
1 parent 5f33bc4 commit 93cb27f
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 61 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ V1.2.39

addtions:
* [core] added OSMF player model
* [core] "streamType" can now be specified separately for each alternate media entry of a playlist item (allows mixing e.g. of RTMP, HTTP for one single playlist item)

fixes:
* [core] fixed jQuery 1.4 issues

changes:
* [core] made OSMF player model default
* [core] missing or broken plugins are now reported via an alert()



Expand Down
38 changes: 22 additions & 16 deletions src/controller/projekktor.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ projekktor = $p = function() {
});
}
}

extRegEx = '^.*\.(' + extRegEx.join('|') + ")$";

// incoming file is a string only, no array
Expand All @@ -411,8 +411,7 @@ projekktor = $p = function() {
if (typeof data.file[index]=='string') {
data.file[index] = {'src':data.file[index]};
}



// nothing to do, next one
if (data.file[index].src==null) {
continue;
Expand All @@ -433,18 +432,20 @@ projekktor = $p = function() {
if (codecMatch[1]!=null) {
data.file[index].codec = codecMatch[1];
}
data.file[index].type = codecMatch[0]; // .replace(/x-/, '');
// data.file[index].originalType = codecMatch[0];
data.file[index].type = codecMatch[0].replace(/x-/, '');
data.file[index].originalType = codecMatch[0];
} catch(e){}
}
else {
data.file[index].type = this._getTypeFromFileExtension( data.file[index].src );
}

if (typesModels[data.file[index].type] .length>0) {
typesModels[data.file[index].type] .sort(function(a, b) {

if (typesModels[data.file[index].type] && typesModels[data.file[index].type].length>0) {

typesModels[data.file[index].type].sort(function(a, b) {
return a.level - b.level;
});
});

modelSets.push(typesModels[data.file[index].type] [0]);
}
}
Expand All @@ -459,14 +460,14 @@ projekktor = $p = function() {
modelSets.sort(function(a, b) {
return a.level - b.level;
});

bestMatch = modelSets[0].level;

modelSets = $.grep(modelSets, function(value) {
return value.level == bestMatch;
});
}

types = [];
$.each(modelSets || [], function() {
types.push(this.type);
Expand Down Expand Up @@ -599,6 +600,11 @@ projekktor = $p = function() {
modelRef.start();
});
break;

case 'availableQualitiesChange':
this.media[this._currentItem].qualities = value;
this._promote('availableQualitiesChange', value);
break;

case 'qualityChange':
this.setConfig({playbackQuality: value});
Expand Down Expand Up @@ -1627,9 +1633,9 @@ projekktor = $p = function() {
return this.playerModel.getMediaDimensions() || {width:0, height:0};
};

this.getAppropriateQuality = function() {
return this._getAppropriateQuality(this.media[this._currentItem].qualities || [])
}
this.getAppropriateQuality = function() {
return this._getAppropriateQuality(this.media[this._currentItem].qualities || [])
}

this._getAppropriateQuality = function(quals) {

Expand Down Expand Up @@ -2778,7 +2784,7 @@ projekktor = $p = function() {
result.playlist[0].push({
src: childNode.attr('src'),
type: childNode.attr('type') || this._getTypeFromFileExtension(childNode.attr('src')),
quality: childNode.attr('data-quality') || ''
quality: childNode.attr('data-quality') || ''
});
break;
case 'TRACK':
Expand All @@ -2805,7 +2811,7 @@ projekktor = $p = function() {
result.playlist[0].push({
src: $(this).attr('src'),
type: $(this).attr('type') || ref._getTypeFromFileExtension($(this).attr('src')),
quality: $(this).attr('data-quality') || ''
quality: $(this).attr('data-quality') || ''
});
break;
case 'TRACK':
Expand Down
28 changes: 23 additions & 5 deletions src/models/player.audio.video.osmf.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $p.newModel({

flashVersion: "10.1",
flashVerifyMethod: 'addEventListener',

iLove: [
{ext:'flv', type:'video/flv', platform:'flash', fixed: true, streamType: ['*']},
{ext:'mp4', type:'video/mp4', platform:'flash', streamType: ['*']},
Expand All @@ -31,6 +32,8 @@ $p.newModel({
isPseudoStream: false,
streamType: 'http',

availableQualities: {},

_isStream: false,
_isMuted: false,
_isStarted: false,
Expand Down Expand Up @@ -215,10 +218,19 @@ $p.newModel({
},

/* todo */
OSMF_updateDynamicStream: function() {
OSMF_updateDynamicStream: function() {
var dynamicStreams = this.mediaElement.get(0).getStreamItems(),
switchMode = this.mediaElement.get(0).getAutoDynamicStreamSwitch() ? "Auto" : "Manual";
// console.log("OSMF_updateDynamicStream", switchMode, dynamicStreams)
name = '';
// switchMode = this.mediaElement.get(0).getAutoDynamicStreamSwitch() ? "Auto" : "Manual";

for (var index in dynamicStreams) {
if (dynamicStreams.hasOwnProperty(index) && dynamicStreams[index].bitrate!==undefined) {
name = dynamicStreams[index].width + "x" + dynamicStreams[index].height;
this.availableQualities[ this.pp.getConfig('OSMFQualityMap') ? this.pp.getConfig('OSMFQualityMap')[name] || name : name] = index;
}
}

this.sendUpdate('availableQualitiesChange', this.availableQualities);
},

/* todo */
Expand All @@ -234,8 +246,14 @@ $p.newModel({
},

errorListener: function() {
if (arguments[0]!==0) {
this.sendUpdate('error', arguments[0]);
switch (arguments[0]) {
case 16:
this.sendUpdate('error', 80);
break;

default:
// this.sendUpdate('error', 0);
break;
}
},

Expand Down
74 changes: 34 additions & 40 deletions src/plugins/projekktor.display.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ projekktorDisplay.prototype = {
staticControls: false,

/* time to delay buffering-icon-overlay once "waiting" event has been triggered */
bufferIconDelay: 1000,
bufferIconDelay: 1,

/* if set the indicator animation is tinkered from a cssprite - must be horizontal */
spriteUrl: '',
Expand All @@ -50,45 +50,39 @@ projekktorDisplay.prototype = {
/* triggered on plugin-instanciation */
initialize: function() {

// create the display container itself
this.display = this.applyToPlayer($('<div/>'));

// create the startbutton
this.startButton = this.applyToPlayer( $('<div/>').addClass('start'), 'startbtn');

// create buffericon
this.buffIcn = this.applyToPlayer( $('<div/>').addClass('buffering'), 'buffericn');
// create the display container itself
this.display = this.applyToPlayer($('<div/>'));

// create the startbutton
this.startButton = this.applyToPlayer( $('<div/>').addClass('start'), 'startbtn');

this.imaContainer = this.applyToPlayer( $('<div/>').addClass('ima'), 'ima');



// create buffericon
this.buffIcn = this.applyToPlayer( $('<div/>').addClass('buffering'), 'buffericn');

this.imaContainer = this.applyToPlayer( $('<div/>').addClass('ima'), 'ima');

this.setActive();

// add spritelayer to buffericon (if required)
if (this.config.spriteUrl!=='') {
this.buffIcnSprite = $('<div/>')
.appendTo(this.buffIcn)
.css({
width: this.config.spriteWidth,
height: this.config.spriteHeight,
marginLeft: ((this.buffIcn.width()-this.config.spriteWidth) / 2)+"px",
marginTop: ((this.buffIcn.height()-this.config.spriteHeight) / 2)+"px",
backgroundColor: 'transparent',
backgroundImage: 'url('+this.config.spriteUrl+')',
backgroundRepeat: 'no-repeat',
backgroundPosition: '0 0'
})
.addClass('inactive');
// add spritelayer to buffericon (if required)
if (this.config.spriteUrl!=='') {
this.buffIcnSprite = $('<div/>')
.appendTo(this.buffIcn)
.css({
width: this.config.spriteWidth,
height: this.config.spriteHeight,
marginLeft: ((this.buffIcn.width()-this.config.spriteWidth) / 2)+"px",
marginTop: ((this.buffIcn.height()-this.config.spriteHeight) / 2)+"px",
backgroundColor: 'transparent',
backgroundImage: 'url('+this.config.spriteUrl+')',
backgroundRepeat: 'no-repeat',
backgroundPosition: '0 0'
})
.addClass('inactive');
}

// create a dedicated media container (if none exists)
this.pp.getMediaContainer();
/*
this.display
.append(this.startButton)
.append(this.buffIcn)
*/
// create a dedicated media container (if none exists)
this.pp.getMediaContainer();

this.pluginReady = true;
},

Expand Down Expand Up @@ -150,7 +144,7 @@ projekktorDisplay.prototype = {
break;

case 'AWAKENING':
// this.hideBufferIcon();;
this.showBufferIcon();
this.hideStartButton();
break;

Expand Down Expand Up @@ -301,15 +295,15 @@ projekktorDisplay.prototype = {
if (this.buffIcn.hasClass('active') ) return;
this.buffIcn.addClass('active').removeClass('inactive');

if (ref.buffIcnSprite==null) return;
if (ref.buffIcnSprite===null) return;

var startOffset=(ref.config.spriteCountUp===true) ? 0 : (ref.config.spriteHeight + ref.config.spriteOffset)*(ref.config.spriteTiles-1),
spriteOffset = startOffset;
ref.buffIcnSprite.addClass('active').removeClass('inactive');
(function() {

if (!ref.buffIcn.is(':visible')) return;
ref.buffIcnSprite.css('backgroundPosition', '0px -'+spriteOffset+"px")
ref.buffIcnSprite.css('backgroundPosition', '0px -'+spriteOffset+"px");

if (ref.config.spriteCountUp===true)
spriteOffset += ref.config.spriteHeight + ref.config.spriteOffset;
Expand All @@ -323,5 +317,5 @@ projekktorDisplay.prototype = {
})();

}
}
});
};
});

0 comments on commit 93cb27f

Please sign in to comment.