diff --git a/src/renderer/pages/player-page.js b/src/renderer/pages/player-page.js index a981837b..783dfaf5 100644 --- a/src/renderer/pages/player-page.js +++ b/src/renderer/pages/player-page.js @@ -549,7 +549,7 @@ function renderPlayerControls (state) { key='scrub-bar' className='scrub-bar' draggable - onMouseOver={handleScrubPreview} + onMouseMove={handleScrubPreview} onMouseOut={clearPreview} onDragStart={handleDragStart} onClick={handleScrub} @@ -779,18 +779,32 @@ function renderPlayerControls (state) { } function renderPreview (state) { - if (!state.playing.preview) { - return null + let { preview } = state.playing + if (!preview) { + preview = { x: 0, time: 0, hide: true } } - const width = 118 + const height = 70 + let width - const xPos = Math.max(state.playing.preview.x - (width / 2), 5) + const previewEl = document.querySelector('video#preview') + if (previewEl !== null && !preview.hide) { + previewEl.currentTime = preview.time + width = (previewEl.videoWidth / previewEl.videoHeight) * height + } + + const windowWidth = document.querySelector('body').clientWidth + const xPos = Math.min(Math.max(preview.x - (width / 2), 5), windowWidth - width - 5) return ( -
{formatTime(state.playing.preview.time, state.playing.duration)}
+{formatTime(preview.time, state.playing.duration)}