Skip to content
This repository was archived by the owner on Oct 20, 2021. It is now read-only.
Merged
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
18 changes: 14 additions & 4 deletions dist/mi-angular-bitdash-player.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/mi-angular-bitdash-player.min.js

Large diffs are not rendered by default.

11 changes: 10 additions & 1 deletion src/bitdash-controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,15 @@ module.exports = function ($scope, $log) {

// copy the basic config ... key is mandatory
vm.config = {};
vm.options = {};
if (angular.isDefined($scope.config) && angular.isDefined($scope.config.key)) {
vm.config = $scope.config;
} else {
$log.error('basic config for bitdash player is missing!');
}
if (angular.isDefined($scope.options)) {
vm.options = $scope.options;
}

// check webcast to expand and manipulate the basic bitdash player config
if (angular.isDefined($scope.webcast)) {
Expand All @@ -25,14 +29,19 @@ module.exports = function ($scope, $log) {

function processWebcast(webcast) {
var stateProperty = webcast.state + 'StateData';

if (angular.isDefined(vm.options.forcedState)) {
stateProperty = vm.options.forcedState + 'StateData';
}

vm.config.source = getPlayerConfigSource(webcast, stateProperty);
vm.config.style = getPlayerConfigStyle(webcast, stateProperty);
}

// player config - source ---------------------------------------------------------------------------------

function getPlayerConfigSource(webcast, state) {
if (webcast.useDVRPlaybackInPostlive === true && webcast.state === 'postlive') {
if (webcast.useDVRPlaybackInPostlive === true && state === 'postliveStateData') {
return getDVRPlaybackToPostlive(webcast);
}

Expand Down
5 changes: 3 additions & 2 deletions src/bitdash-directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ module.exports = function ($window) {
templateUrl: 'mi/template/bitdash-player.html',
scope: {
config: '=',
webcast: '='
webcast: '=',
options: '=?'

},
link: function (scope) {
var config = scope.config; // die config wird automatisch durch den controller erweitert
var player = $window.window.bitdash('mi-bitdash-player');

// tech support - flash and hls
var supportedTech = player.getSupportedTech();
// force HLS / Flash playback if available
Expand Down
16 changes: 14 additions & 2 deletions test/bitdash-controller.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ describe('BitdashController', function () {
'videodb_519_76439_7579412_16x9_hd.mp4/master.m3u8');
expect(vm.config.style.autoHideControls).toBeTruthy();
expect(vm.config.style.aspectratio).toBe('16:9');

});


it('should configure the player DVR Record in postlive', function () {
$scope.webcast.useDVRPlaybackInPostlive = true;
var vm = createController();
Expand All @@ -104,4 +102,18 @@ describe('BitdashController', function () {
expect($scope.audioOnlyStillImageUrl).toContain('data:image/jpeg;base64,');
expect(vm.config.style.aspectratio).toBeUndefined();
});

it('should configure the player without forced state', function() {
var vm = createController();
expect(vm.config.source.hls).toBe('http://hd2.cdn.edge-cdn.net/i/videodb/519/' +
'videodb_519_76439_7579412_16x9_hd.mp4/master.m3u8');
expect(vm.config.source.dash).toBe('https://live-origin.edge-cdn.net/webcast/myStream/manifest.mpd');
});

it('should configure the player with forced live state', function() {
$scope.options = {forcedState: 'live'};
var vm = createController();
expect(vm.config.source.hls).toBe('https://live-origin.edge-cdn.net/webcast/myStream/master.m3u8');
expect(vm.config.source.dash).toBe('https://live-origin.edge-cdn.net/webcast/myStream/manifest.mpd');
});
});
74 changes: 74 additions & 0 deletions test/bitdash-directive.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,78 @@ describe('BitdashDirective', function () {
expect(player.destroy).not.toHaveBeenCalled();
expect(player.setup).toHaveBeenCalledWith({foo: 'bar'}, 'flash.hls');
}));

it('Should set up the player without options attribute', angular.mock.inject(function ($compile, $rootScope) {
$rootScope.webcastMainVm = {playerConfig: {foo: 'bar'}, webcast: {
state: 'postlive',
postliveStateData: {
playout: {
audioOnly: true
}
}
}};
var elem = angular.element(template);
var element = $compile(elem)($rootScope);
$rootScope.$apply();
var scope = element.isolateScope();
expect(scope.options).toBeUndefined();
}));

it('Should set up the player without otions', angular.mock.inject(function ($compile, $rootScope) {
$rootScope.webcastMainVm = {playerConfig: {foo: 'bar'}, webcast: {
state: 'postlive',
postliveStateData: {
playout: {
audioOnly: true
}
}
}};
template = '<mi-bitdash-player config="webcastMainVm.playerConfig"' +
' webcast="webcastMainVm.webcast" options="webcastMainVm.options"></mi-bitdash-player>';
var elem = angular.element(template);
var element = $compile(elem)($rootScope);
$rootScope.$apply();
var scope = element.isolateScope();
expect(scope.options).toBeUndefined();
}));

it('Should set up the player without forced state', angular.mock.inject(function ($compile, $rootScope) {
$rootScope.webcastMainVm = {playerConfig: {foo: 'bar'}, webcast: {
state: 'postlive',
postliveStateData: {
playout: {
audioOnly: true
}
}
},
options: {speak: 'spell'}};
template = '<mi-bitdash-player config="webcastMainVm.playerConfig"' +
' webcast="webcastMainVm.webcast" options="webcastMainVm.options"></mi-bitdash-player>';
var elem = angular.element(template);
var element = $compile(elem)($rootScope);
$rootScope.$apply();
var scope = element.isolateScope();
expect(scope.options).toBeDefined();
expect(scope.options.forcedState).toBeUndefined();
}));

it('Should set up the player with forced live state', angular.mock.inject(function ($compile, $rootScope) {
$rootScope.webcastMainVm = {playerConfig: {foo: 'bar'}, webcast: {
state: 'postlive',
postliveStateData: {
playout: {
audioOnly: true
}
}
},
options: {forcedState: 'live'}
};
template = '<mi-bitdash-player config="webcastMainVm.playerConfig"' +
' webcast="webcastMainVm.webcast" options="webcastMainVm.options"></mi-bitdash-player>';
var elem = angular.element(template);
var element = $compile(elem)($rootScope);
$rootScope.$apply();
var scope = element.isolateScope();
expect(scope.options.forcedState).toBe('live');
}));
});