Skip to content

Commit

Permalink
fix(FEC-8719): volume is not in sync when switching between sender-re…
Browse files Browse the repository at this point in the history
…ceiver (#189)

* FEC-8595

* Update player-snapshot.js

* fix build

* FEC-8719
  • Loading branch information
Dan Ziv authored and odedhutzler committed Dec 16, 2018
1 parent 8825fae commit 222d214
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 0 additions & 2 deletions src/common/cast/player-snapshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ class PlayerSnapshot {
playback: {
startTime: getStartTime(player),
autoplay: player.currentTime === 0 ? true : !player.paused,
volume: player.volume,
muted: player.muted,
audioLanguage: getLanguage(TrackType.AUDIO, player),
textLanguage: getLanguage(TrackType.TEXT, player)
}
Expand Down
8 changes: 1 addition & 7 deletions src/common/cast/remote-control.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ function onRemoteDeviceDisconnected(payload: RemoteDisconnectedPayload): void {
if (mediaInfo) {
this.loadMedia(mediaInfo).then(() => {
this._eventManager.listenOnce(this, this.Event.Core.FIRST_PLAYING, () => {
setInitialAttributes.call(this, snapshot);
this.textStyle = snapshot.textStyle;
configurePlayback.call(this, originPlaybackConfig);
setInitialTracks.call(this, snapshot);
});
Expand Down Expand Up @@ -217,12 +217,6 @@ function configurePlayback(playbackConfig: Object): void {
});
}

function setInitialAttributes(snapshot: PlayerSnapshot): void {
this.textStyle = snapshot.textStyle;
this.volume = snapshot.config.playback.volume;
this.muted = snapshot.config.playback.muted;
}

function setInitialTracks(playbackConfig: Object): void {
if (playbackConfig.audioLanguage) {
const audioTrack = this.getTracks(TrackType.AUDIO).find(t => t.language === playbackConfig.audioLanguage);
Expand Down
12 changes: 9 additions & 3 deletions src/common/storage/storage-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,19 @@ export default class StorageManager {
static attach(player: Player): void {
StorageManager._logger.debug('Attach local storage');
player.addEventListener(player.Event.UI.USER_CLICKED_MUTE, () => {
StorageWrapper.setItem(StorageManager.StorageKeys.MUTED, player.muted);
if (!player.isCasting()) {
StorageWrapper.setItem(StorageManager.StorageKeys.MUTED, player.muted);
}
});
player.addEventListener(player.Event.UI.USER_CLICKED_UNMUTE, () => {
StorageWrapper.setItem(StorageManager.StorageKeys.MUTED, player.muted);
if (!player.isCasting()) {
StorageWrapper.setItem(StorageManager.StorageKeys.MUTED, player.muted);
}
});
player.addEventListener(player.Event.UI.USER_CHANGED_VOLUME, () => {
StorageWrapper.setItem(StorageManager.StorageKeys.VOLUME, player.volume);
if (!player.isCasting()) {
StorageWrapper.setItem(StorageManager.StorageKeys.VOLUME, player.volume);
}
});
player.addEventListener(player.Event.UI.USER_SELECTED_AUDIO_TRACK, event => {
const audioTrack = event.payload.audioTrack;
Expand Down

0 comments on commit 222d214

Please sign in to comment.