Skip to content

Commit

Permalink
fix(standard): player not becoming active
Browse files Browse the repository at this point in the history
  • Loading branch information
mihar-22 committed Apr 10, 2020
1 parent fc724c4 commit 0c8817c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
16 changes: 12 additions & 4 deletions packages/vime-standard/src/StandardPlayer.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,15 @@
let self = get_current_component();
// eslint-disable-next-line no-underscore-dangle
export let _standardStore = buildStandardStore(self);
const { store, resetStore, onPropsChange } = _standardStore;
export let _standardStore = null;
let onPropsChange = noop;
if (is_null(_standardStore)) {
_standardStore = buildStandardStore(self);
({ onPropsChange } = _standardStore);
}
const { store, resetStore } = _standardStore;
$: onPropsChange($$props);
const {
Expand All @@ -57,7 +64,7 @@
currentTrackIndex, provider, rebuilding,
isVideoReady, canInteract, isFullscreenActive,
useNativeView, useNativeControls, useNativeCaptions,
duration, Provider,
duration, Provider, isPlayerActive,
} = store;
const {
Expand Down Expand Up @@ -86,7 +93,8 @@
self = null;
});
$: if (!$currentPlayer) $currentPlayer = self;
if (is_null(currentPlayer)) currentPlayer.set(self);
$: $isPlayerActive = ($currentPlayer === self);
// --------------------------------------------------------------
// Provider Events
Expand Down
3 changes: 1 addition & 2 deletions packages/vime-standard/src/standardStore.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { writable, derived } from 'svelte/store';
import { currentPlayer } from './sharedStore';
import PlayerState from './PlayerState';
import MediaType from './MediaType';
import VideoQuality from './VideoQuality';
Expand Down Expand Up @@ -187,7 +186,7 @@ export const buildStandardStore = (player) => {
store.playbackEnded = private_writable(defaults.playbackEnded);
store.playbackStarted = private_writable(defaults.playbackStarted);
store.seeking = private_writable(defaults.seeking);
store.isPlayerActive = derived(currentPlayer, ($currentPlayer) => $currentPlayer === player);
store.isPlayerActive = private_writable(false);

store.state = derived(
[
Expand Down

0 comments on commit 0c8817c

Please sign in to comment.