Skip to content

Commit

Permalink
fix: set playlist by configure method doesn't work (#197)
Browse files Browse the repository at this point in the history
support `playlist` config in `configure` method
  • Loading branch information
yairans authored Jan 8, 2019
1 parent 4ffde1b commit 7f4c515
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 46 deletions.
90 changes: 46 additions & 44 deletions samples/ovp/playlist-by-config.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,59 +21,61 @@
},
playback: {
autoplay: true
},
playlist: {
id: '1234',
metadata: {
name: 'my playlist name',
description: 'my playlist desc'
},
items: [{
sources: {
poster: 'http://cdntesting.qa.mkaltura.com/p/1091/sp/109100/thumbnail/entry_id/0_fu4ifhie/version/100002/height/360/width/640',
hls: [
{
id: "id1",
mimetype: "application/x-mpegURL",
url: "http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_fu4ifhie/protocol/http/format/applehttp/flavorIds/0_wbawecj0,0_cj2odpyt,0_uj45vim0,0_xlpm7btj,0_6p25la0i,0_cmq5aigy/a.m3u8"
}
]
}
},
{
sources: {
metadata: {
name: 'my second entry'
},
hls: [
{
id: "id2",
mimetype: "application/x-mpegURL",
url: "http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_15xrxwvo/protocol/http/format/applehttp/flavorIds/0_io24exzg,0_5r0geh30,0_b647tbfs,0_fzqa9ew4/a.m3u8"
}
]
}
}
};

try {
var kalturaPlayer = KalturaPlayer.setup(config);
kalturaPlayer.configure({
playlist: {
id: '1234',
metadata: {
name: 'my playlist name',
description: 'my playlist desc'
},
{
items: [{
sources: {
poster: 'http://cdntesting.qa.mkaltura.com/p/1091/sp/109100/thumbnail/entry_id/0_fu4ifhie/version/100002/height/360/width/640',
hls: [
{
id: "id3",
id: "id1",
mimetype: "application/x-mpegURL",
url: "http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_p8aigvgu/protocol/http/format/applehttp/flavorIds/0_80115tmg/a.m3u8"
url: "http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_fu4ifhie/protocol/http/format/applehttp/flavorIds/0_wbawecj0,0_cj2odpyt,0_uj45vim0,0_xlpm7btj,0_6p25la0i,0_cmq5aigy/a.m3u8"
}
]
}
}],
countdown: {
duration: 10,
showing: true
},
{
sources: {
metadata: {
name: 'my second entry'
},
hls: [
{
id: "id2",
mimetype: "application/x-mpegURL",
url: "http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_15xrxwvo/protocol/http/format/applehttp/flavorIds/0_io24exzg,0_5r0geh30,0_b647tbfs,0_fzqa9ew4/a.m3u8"
}
]
}
},
{
sources: {
hls: [
{
id: "id3",
mimetype: "application/x-mpegURL",
url: "http://qa-apache-php7.dev.kaltura.com/p/1091/sp/109100/playManifest/entryId/0_p8aigvgu/protocol/http/format/applehttp/flavorIds/0_80115tmg/a.m3u8"
}
]
}
}],
countdown: {
duration: 10,
showing: true
}
}
}
};

try {
var kalturaPlayer = KalturaPlayer.setup(config);
});
} catch (e) {
console.error(e.message)
}
Expand Down
3 changes: 3 additions & 0 deletions src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,9 @@ class KalturaPlayer extends FakeEventTarget {
if (config.ui) {
this._uiWrapper.setConfig(config.ui);
}
if (config.playlist) {
this._playlistManager.configure(config.playlist);
}
}

ready(): Promise<*> {
Expand Down
50 changes: 48 additions & 2 deletions test/src/kaltura-player.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ describe('kaltura player api', function() {
});
});

describe('load playlist by config', function() {
describe('load playlist by setup config', function() {
beforeEach(function() {
config.playlist = PlaylistMockData.playlistByConfig;
kalturaPlayer = setup(config);
Expand All @@ -194,7 +194,28 @@ describe('kaltura player api', function() {
});
});

describe('mix config and api', function() {
describe('load playlist by configure', function() {
beforeEach(function() {
kalturaPlayer = setup(config);
});

it('should set the configured playlist', function(done) {
kalturaPlayer.addEventListener('kaltura-player-playlistloaded', event => {
event.payload.playlist.id.should.equal('b1234');
kalturaPlayer.playlist.id.should.equal('b1234');
kalturaPlayer.playlist.metadata.name.should.equal('my playlist name');
kalturaPlayer.playlist.metadata.description.should.equal('my playlist desc');
kalturaPlayer.playlist.poster.should.equal('http://cdntesting.qa.mkaltura.com/p/1091/sp/0/thumbnail/entry_id/0_wckoqjnn/version/100162');
kalturaPlayer.playlist.items.length.should.equal(3);
kalturaPlayer.playlist.countdown.duration.should.equal(20);
kalturaPlayer.playlist.options.autoContinue.should.be.false;
done();
});
kalturaPlayer.configure({playlist: PlaylistMockData.playlistByConfig});
});
});

describe('mix setup config and api', function() {
beforeEach(function() {
config.playlist = {
countdown: {
Expand All @@ -216,5 +237,30 @@ describe('kaltura player api', function() {
kalturaPlayer.playlist.countdown.duration.should.equal(20);
});
});

describe('mix configure and api', function() {
beforeEach(function() {
kalturaPlayer = setup(config);
});

it('should load the playlist with the preset config', function() {
kalturaPlayer.configure({
playlist: {
countdown: {
duration: 20,
showing: true
},
options: {
autoContinue: false
}
}
});
kalturaPlayer.setPlaylist({id: 'a12345', items: []}, {countdown: {showing: false}});
kalturaPlayer.playlist.id.should.equal('a12345');
kalturaPlayer.playlist.options.autoContinue.should.be.false;
kalturaPlayer.playlist.countdown.showing.should.be.false;
kalturaPlayer.playlist.countdown.duration.should.equal(20);
});
});
});
});

0 comments on commit 7f4c515

Please sign in to comment.