Skip to content

Commit

Permalink
Fix bug where initial track duration is always derived from first track.
Browse files Browse the repository at this point in the history
  • Loading branch information
benwiley4000 committed Apr 21, 2019
1 parent 0643530 commit ac4b6ab
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/core/src/PlayerContextProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class PlayerContextProvider extends Component {
constructor(props) {
super(props);
let currentTime = 0;
const activeTrackIndex = convertToNumberWithinIntervalBounds(
let activeTrackIndex = convertToNumberWithinIntervalBounds(
props.startingTrackIndex,
0
);
Expand All @@ -127,6 +127,16 @@ export class PlayerContextProvider extends Component {
initialStateSnapshot,
props
);
const {
activeTrackIndex: a,
currentTime: c
} = restoredStateFromSnapshot;
if (typeof a === 'number') {
activeTrackIndex = a;
}
if (typeof c === 'number') {
currentTime = c;
}
} catch (err) {
logWarning(err);
logWarning('Loading Cassette state from snapshot failed.');
Expand Down

2 comments on commit ac4b6ab

@benwiley4000
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danielr18 you may have run into this... previously we would only load the duration property from the first track because we set the activeTrackIndex before loading the state snapshot. I'll release soon in v2.0.0-beta.1.

@danielr18
Copy link
Contributor

@danielr18 danielr18 commented on ac4b6ab Apr 21, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, perhaps I never saw this issue because active track is always the first track in OwlTail. Thanks for letting me know.

Please sign in to comment.