Skip to content

Commit

Permalink
bug: fix player button press when playing (#1772)
Browse files Browse the repository at this point in the history
  • Loading branch information
w3cj authored Aug 9, 2024
1 parent bb04406 commit 43cff85
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
16 changes: 14 additions & 2 deletions src/routes/(site)/show/[show_number]/[slug]/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,19 @@
}
function play_show() {
player.start_show(show, time_param_to_seconds(time_start));
if ($player.current_show?.number !== show.number || $player.status === 'INITIAL') {
player.start_show(show, time_param_to_seconds(time_start));
} else if ($player.status === 'PLAYING') {
player.pause();
} else {
player.play();
}
}
function variable_svg(node: HTMLElement) {
replace_color(node);
}
</script>

<header>
Expand Down Expand Up @@ -82,7 +89,12 @@
? 'ing'
: ''}"
/>
Play{$player.current_show?.number === show.number ? 'ing' : ''} Episode {show.number}
{#if $player.status === 'PAUSED' && $player.current_show?.number === show.number}
Resume
{:else}
Play{$player.current_show?.number === show.number ? 'ing' : ''}
{/if}
Episode {show.number}
</button>
<span>or</span>
<ListenLinks {show} />
Expand Down
3 changes: 2 additions & 1 deletion src/state/player.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ const new_player_state = () => {
state.audio.src = incoming_show.url;
state.audio.currentTime = resume_time;
state.current_show = incoming_show;
state.status = 'LOADED';
state.status = resume_time > 0 ? 'PAUSED' : 'LOADED';
}
return state;
});
Expand Down Expand Up @@ -179,6 +179,7 @@ const new_player_state = () => {
// Finally Start Playing
this.play();
} catch (error) {
console.log('setting initial...');
update((state) => ({ ...state, status: 'INITIAL' }));
}
},
Expand Down

0 comments on commit 43cff85

Please sign in to comment.