Skip to content

Commit

Permalink
feat(FEC-9175): cast content coming from external sources (#288)
Browse files Browse the repository at this point in the history
Implement `getMediaConfig` api
  • Loading branch information
yairans committed Dec 3, 2019
1 parent 302adb8 commit 43a46b2
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 2 deletions.
8 changes: 8 additions & 0 deletions src/common/cast/base-remote-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,14 @@ class BaseRemotePlayer extends FakeEventTarget implements IRemotePlayer {
*/
getMediaInfo(): ?Object {}

/**
* Gets the media config.
* @returns {?Object} - The media config.
* @instance
* @memberof BaseRemotePlayer
*/
getMediaConfig(): ?Object {}

/**
* Configure the remote player
* @param {Object} config - Configuration to set.
Expand Down
2 changes: 2 additions & 0 deletions src/common/cast/player-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {TextStyle, TrackType, Utils} from '@playkit-js/playkit-js';
*/
class PlayerSnapshot {
mediaInfo: ?ProviderMediaInfoObject;
mediaConfig: ?ProviderMediaConfigObject;
/**
* @type {TextStyle}
* @instance
Expand All @@ -31,6 +32,7 @@ class PlayerSnapshot {
constructor(player: KalturaPlayer) {
this.textStyle = player.textStyle;
this.mediaInfo = player.getMediaInfo();
this.mediaConfig = player.getMediaConfig();
this.advertising = player.config.plugins && player.config.plugins.ima;
this.config = Utils.Object.mergeDeep({}, player.config, {
playback: {
Expand Down
11 changes: 9 additions & 2 deletions src/common/cast/remote-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,18 @@ function onRemoteDeviceDisconnected(payload: RemoteDisconnectedPayload): void {
const originPlaybackConfig = this.config.playback;
const shouldPause = !snapshot.config.playback.autoplay;
const mediaInfo = snapshot.mediaInfo;
const mediaConfig = snapshot.mediaConfig;
snapshot.config.playback.autoplay = true;
configurePlayback.call(this, snapshot.config.playback);
let mediaPromise;
if (mediaInfo) {
this.loadMedia(mediaInfo).then(() => {
mediaPromise = this.loadMedia(mediaInfo);
} else if (mediaConfig) {
mediaPromise = Promise.resolve();
this.setMedia(mediaConfig);
}
mediaPromise &&
mediaPromise.then(() => {
this._eventManager.listenOnce(this, this.Event.Core.FIRST_PLAYING, () => {
this.textStyle = snapshot.textStyle;
configurePlayback.call(this, originPlaybackConfig);
Expand All @@ -153,7 +161,6 @@ function onRemoteDeviceDisconnected(payload: RemoteDisconnectedPayload): void {
}
});
});
}
}
}
}
Expand Down
8 changes: 8 additions & 0 deletions src/common/cast/remote-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ export interface IRemotePlayer {
*/
getMediaInfo(): ?Object;

/**
* @method
* @returns {Object}
* @instance
* @memberof IRemotePlayer
*/
getMediaConfig(): ?Object;

/**
* @method
* @param {Object} config
Expand Down
8 changes: 8 additions & 0 deletions src/kaltura-player.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,14 @@ class KalturaPlayer extends FakeEventTarget {
return Utils.Object.copyDeep(this._mediaInfo);
}

getMediaConfig(): ?ProviderMediaConfigObject {
const mediaConfig = {
sources: this._localPlayer.config.sources,
plugins: this._localPlayer.config.plugins
};
return Utils.Object.copyDeep(mediaConfig);
}

/**
* Config the player.
* @param {Object} [config={}] - The player config.
Expand Down

0 comments on commit 43a46b2

Please sign in to comment.