Skip to content

Commit

Permalink
sync-from-video UX improvements
Browse files Browse the repository at this point in the history
- Display subtitle file name in video element when it's loaded
- Fade-in asbplayer logo on drag over video element
  • Loading branch information
killergerbah committed May 25, 2021
1 parent 29534f3 commit 3ca2f39
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
6 changes: 3 additions & 3 deletions client/src/components/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ export default function Player(props) {

if (subtitlesRef.current) {
channel.subtitleSettings(settingsProvider.subtitleSettings);
channel.subtitles(subtitlesRef.current);
channel.subtitles(subtitlesRef.current, subtitleFile?.name);
}

channel.condensedModeToggle(condensedModeEnabledRef.current);
Expand Down Expand Up @@ -473,12 +473,12 @@ export default function Player(props) {
displayTime: timeDuration(s.originalStart + offset, length)
}));

videoRef.current?.subtitles(newSubtitles);
videoRef.current?.subtitles(newSubtitles, subtitleFile?.name);

return newSubtitles;
});

}, [offset, offsetRef]);
}, [subtitleFile, offset, offsetRef]);

const handleVolumeChange = useCallback((v) => {
if (audioRef.current) {
Expand Down
4 changes: 2 additions & 2 deletions client/src/services/VideoChannel.js
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ export default class VideoChannel {
this.protocol.postMessage({command: 'audioTrackSelected', id: id});
}

subtitles(subtitles) {
this.protocol.postMessage({command: 'subtitles', value: subtitles});
subtitles(subtitles, subtitleFileName) {
this.protocol.postMessage({command: 'subtitles', value: subtitles, name: subtitleFileName});
}

subtitleSettings(settings) {
Expand Down
15 changes: 15 additions & 0 deletions extension/video.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,21 @@
pointer-events: none;
}

.asbplayer-drag-image-fade-in {
animation-duration: 0.2s;
animation-name: asbplayer-fade-in;
}

@keyframes asbplayer-fade-in {
from {
opacity: 0;
}

to {
opacity: 1;
}
}

.asbplayer-drag-image-container {
position: absolute;
pointer-events: none;
Expand Down
5 changes: 4 additions & 1 deletion extension/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ class Binding {
break;
case 'subtitles':
this.subtitleContainer.subtitles = request.message.value;
this.subtitleContainer.showLoadedMessage("[Subtitles Loaded]");
this.subtitleContainer.showLoadedMessage(request.message.name || "[Subtitles Loaded]");
break;
case 'subtitleSettings':
this.subtitleContainer.subtitleSettings = request.message.value;
Expand Down Expand Up @@ -721,6 +721,7 @@ class DragContainer {
e.preventDefault();
this.dragEnterElement = null;
this._imageElement().classList.add("asbplayer-hide");
this._imageElement().classList.remove("asbplayer-drag-image-fade-in");
this._dragElement().classList.remove("asbplayer-drag-zone-dragging");

if (!e.dataTransfer.files || e.dataTransfer.files.length === 0) {
Expand Down Expand Up @@ -748,6 +749,7 @@ class DragContainer {
e.stopPropagation();
this.dragEnterElement = e.target;
this._imageElement().classList.remove("asbplayer-hide");
this._imageElement().classList.add("asbplayer-drag-image-fade-in");
};

this.bodyDragEnterListener = (e) => {
Expand All @@ -762,6 +764,7 @@ class DragContainer {

if (this.dragEnterElement === e.target) {
this._imageElement().classList.add("asbplayer-hide");
this._imageElement().classList.remove("asbplayer-drag-image-fade-in");
this._dragElement().classList.remove("asbplayer-drag-zone-dragging");
}
};
Expand Down

0 comments on commit 3ca2f39

Please sign in to comment.