Skip to content

Commit

Permalink
Add infinity play option (#93)
Browse files Browse the repository at this point in the history
* ft: added infinity play, added buttons; added muted

* Fix video autoplay

* Update CHANGELOG.md

* Update CHANGELOG.md

* Update auto play description to highlight that auto played video will be muted

---------

Co-authored-by: asimonok <[email protected]>
Co-authored-by: Mikhail Volkov <[email protected]>
  • Loading branch information
3 people authored Feb 23, 2024
1 parent d3db3b0 commit 0272878
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# Changelog

## 4.2.0 (IN PROGRESS)
## 4.2.0 (2024-02-22)

### Features / Enhancements

- Update ESLint configuration and refactoring (#92)
- Update dependencies and Actions (#94)
- Add infinity play option (#93)

## 4.1.0 (2023-10-29)

Expand Down
9 changes: 8 additions & 1 deletion src/components/ImagePanel/ImagePanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -289,9 +289,11 @@ export const ImagePanel: React.FC<Props> = ({ options, data, width, height, repl
if (type === SupportedFileType.MP4 || type === SupportedFileType.WEBM) {
return renderContainer(
<video
muted={options.autoPlay}
width={imageWidth || ''}
height={imageHeight || ''}
controls={options.controls}
loop={options.infinityPlay}
autoPlay={options.autoPlay}
data-testid={TEST_IDS.panel.video}
>
Expand All @@ -305,7 +307,12 @@ export const ImagePanel: React.FC<Props> = ({ options, data, width, height, repl
*/
if (type === SupportedFileType.MP3 || type === SupportedFileType.OGG) {
return renderContainer(
<audio controls={options.controls} autoPlay={options.autoPlay} data-testid={TEST_IDS.panel.audio}>
<audio
controls={options.controls}
autoPlay={options.autoPlay}
data-testid={TEST_IDS.panel.audio}
loop={options.infinityPlay}
>
<source src={img} />
</audio>
);
Expand Down
1 change: 1 addition & 0 deletions src/constants/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ImageScale, ImageSizeMode, PanelOptions, ZoomType } from '../types';
*/
export const DEFAULT_OPTIONS: PanelOptions = {
autoPlay: true,
infinityPlay: false,
buttons: [],
controls: true,
description: '',
Expand Down
15 changes: 14 additions & 1 deletion src/module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ export const plugin = new PanelPlugin<PanelOptions>(ImagePanel).setNoPadding().s
.addRadio({
path: 'autoPlay',
name: 'Auto Play',
description: 'When enabled, the video and audio will automatically start playing.',
description: 'When enabled, the video and audio will automatically start playing without sound.',
settings: {
options: [
{ value: true, label: 'Enabled' },
Expand All @@ -188,6 +188,19 @@ export const plugin = new PanelPlugin<PanelOptions>(ImagePanel).setNoPadding().s
},
category: ['Video/Audio'],
defaultValue: DEFAULT_OPTIONS.autoPlay,
})
.addRadio({
path: 'infinityPlay',
name: 'Infinity Play',
description: 'When enabled, the video and audio will be played back repeatedly.',
settings: {
options: [
{ value: true, label: 'Enabled' },
{ value: false, label: 'Disabled' },
],
},
category: ['Video/Audio'],
defaultValue: DEFAULT_OPTIONS.infinityPlay,
});

return builder;
Expand Down
7 changes: 7 additions & 0 deletions src/types/panel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ export interface PanelOptions {
*/
autoPlay: boolean;

/**
* Infinity Play
*
* @type {boolean}
*/
infinityPlay: boolean;

/**
* Toolbar
*
Expand Down

0 comments on commit 0272878

Please sign in to comment.