mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
UI, volume, and seek fixes
This commit is contained in:
parent
755db076e7
commit
ad9763614c
3 changed files with 8 additions and 4 deletions
|
@ -182,6 +182,7 @@ export class Player {
|
|||
if (Number.isNaN(dashBufferLength))
|
||||
dashBufferLength = 0;
|
||||
|
||||
dashBufferLength += dashPlayer.time();
|
||||
return dashBufferLength;
|
||||
} else { // HLS, HTML
|
||||
const videoPlayer = this.player as HTMLVideoElement;
|
||||
|
|
|
@ -249,6 +249,8 @@ window.electronAPI.onPlay((_event, value: PlayMessage) => {
|
|||
playerPrevTime = videoElement.currentTime;
|
||||
}
|
||||
};
|
||||
// Buffering UI update when paused
|
||||
videoElement.onprogress = () => { playerCtrlStateUpdate(PlayerControlEvent.TimeUpdate); };
|
||||
videoElement.onratechange = () => { sendPlaybackUpdate(videoElement.paused ? 2 : 1) };
|
||||
videoElement.onvolumechange = () => {
|
||||
playerCtrlStateUpdate(PlayerControlEvent.VolumeChange);
|
||||
|
@ -266,8 +268,8 @@ window.electronAPI.onPlay((_event, value: PlayMessage) => {
|
|||
// Sender generated event handlers
|
||||
window.electronAPI.onPause(() => { playerCtrlStateUpdate(PlayerControlEvent.Pause); });
|
||||
window.electronAPI.onResume(() => { playerCtrlStateUpdate(PlayerControlEvent.Play); });
|
||||
window.electronAPI.onSeek((_event, value: SeekMessage) => { console.log("electron on seek " + value.time); player.setCurrentTime(value.time); });
|
||||
window.electronAPI.onSetVolume((_event, value: SetVolumeMessage) => { player.setVolume(value.volume); playerCtrlStateUpdate(PlayerControlEvent.VolumeChange); });
|
||||
window.electronAPI.onSeek((_event, value: SeekMessage) => { player.setCurrentTime(value.time); });
|
||||
window.electronAPI.onSetVolume((_event, value: SetVolumeMessage) => { volumeChangeHandler(value.volume); });
|
||||
window.electronAPI.onSetSpeed((_event, value: SetSpeedMessage) => { player.setPlaybackRate(value.speed); playerCtrlStateUpdate(PlayerControlEvent.SetPlaybackRate); });
|
||||
});
|
||||
|
||||
|
@ -324,7 +326,7 @@ function playerCtrlStateUpdate(event: PlayerControlEvent) {
|
|||
|
||||
case PlayerControlEvent.ToggleMute:
|
||||
player.setMute(!player.isMuted());
|
||||
break;
|
||||
// fallthrough
|
||||
|
||||
case PlayerControlEvent.VolumeChange: {
|
||||
const volume = Math.round(player.getVolume() * playerCtrlVolumeBar.offsetWidth);
|
||||
|
@ -352,7 +354,7 @@ function playerCtrlStateUpdate(event: PlayerControlEvent) {
|
|||
const progress = Math.round((player.getCurrentTime() / player.getDuration()) * playerCtrlProgressBar.offsetWidth);
|
||||
const handle = progress + playerCtrlProgressBar.offsetLeft;
|
||||
|
||||
playerCtrlProgressBarBuffer.setAttribute("style", `width: ${progress + buffer}px`);
|
||||
playerCtrlProgressBarBuffer.setAttribute("style", `width: ${buffer}px`);
|
||||
playerCtrlProgressBarProgress.setAttribute("style", `width: ${progress}px`);
|
||||
playerCtrlProgressBarHandle.setAttribute("style", `left: ${handle}px`);
|
||||
|
||||
|
|
|
@ -177,6 +177,7 @@ body {
|
|||
left: 8px;
|
||||
bottom: 8px;
|
||||
height: 4px;
|
||||
width: 0px;
|
||||
background-color: #019BE7;
|
||||
border-radius: 3px;
|
||||
pointer-events: none;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue