Skip to content

Commit

Permalink
feat: adding optional support for auto playing and looping videos (#1…
Browse files Browse the repository at this point in the history
…84758)

* feat: adding options to support videos looping and auto playing

Signed-off-by: Fawzi Abdulfattah <[email protected]>

* chore: adding on mute to the videos auto play setting's description

Signed-off-by: Fawzi Abdulfattah <[email protected]>

---------

Signed-off-by: Fawzi Abdulfattah <[email protected]>
  • Loading branch information
iifawzi authored Jun 21, 2023
1 parent 7c2d459 commit 46e83a2
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extensions/media-preview/media/videoPreview.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
}
video.playsInline = true;
video.controls = true;
video.autoplay = settings.autoplay;
video.muted = settings.autoplay;
video.loop = settings.loop;

function onLoaded() {
if (hasLoadedMedia) {
Expand Down
16 changes: 16 additions & 0 deletions extensions/media-preview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@
}
},
"contributes": {
"configuration": {
"type": "object",
"title": "Media Previewer",
"properties": {
"previewer.videos.autoPlay": {
"type": "boolean",
"default": false,
"markdownDescription": "%videoPreviewerAutoPlay%"
},
"previewer.videos.loop": {
"type": "boolean",
"default": false,
"markdownDescription": "%videoPreviewerLoop%"
}
}
},
"customEditors": [
{
"viewType": "imagePreview.previewEditor",
Expand Down
2 changes: 2 additions & 0 deletions extensions/media-preview/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"customEditor.audioPreview.displayName": "Audio Preview",
"customEditor.imagePreview.displayName": "Image Preview",
"customEditor.videoPreview.displayName": "Video Preview",
"videoPreviewerAutoPlay": "Start playing videos on mute automatically.",
"videoPreviewerLoop": "Loop videos over again automatically.",
"command.zoomIn": "Zoom in",
"command.zoomOut": "Zoom out",
"command.copyImage": "Copy"
Expand Down
3 changes: 3 additions & 0 deletions extensions/media-preview/src/videoPreview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,11 @@ class VideoPreview extends MediaPreview {

protected async getWebviewContents(): Promise<string> {
const version = Date.now().toString();
const configurations = vscode.workspace.getConfiguration('previewer.videos');
const settings = {
src: await this.getResourcePath(this.webviewEditor, this.resource, version),
autoplay: configurations.get('autoPlay'),
loop: configurations.get('loop'),
};

const nonce = getNonce();
Expand Down

0 comments on commit 46e83a2

Please sign in to comment.