Merge pull request #29 from ismaelpadilla/sound

Add sound toggle
This commit is contained in:
Ismael Padilla 2022-03-15 13:52:41 -03:00 committed by GitHub
commit 827bdd160e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 47 additions and 8 deletions

20
package-lock.json generated
View File

@ -1,12 +1,11 @@
{ {
"name": "reddit-slideshow", "name": "reddit-slideshow",
"version": "0.1.4", "version": "0.1.6",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "reddit-slideshow", "version": "0.1.6",
"version": "0.1.4",
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",
"react": "^16.13.1", "react": "^16.13.1",
@ -3950,6 +3949,7 @@
"dependencies": { "dependencies": {
"anymatch": "~3.1.1", "anymatch": "~3.1.1",
"braces": "~3.0.2", "braces": "~3.0.2",
"fsevents": "~2.1.2",
"glob-parent": "~5.1.0", "glob-parent": "~5.1.0",
"is-binary-path": "~2.1.0", "is-binary-path": "~2.1.0",
"is-glob": "~4.0.1", "is-glob": "~4.0.1",
@ -5699,7 +5699,8 @@
"esprima": "^4.0.1", "esprima": "^4.0.1",
"estraverse": "^4.2.0", "estraverse": "^4.2.0",
"esutils": "^2.0.2", "esutils": "^2.0.2",
"optionator": "^0.8.1" "optionator": "^0.8.1",
"source-map": "~0.6.1"
}, },
"bin": { "bin": {
"escodegen": "bin/escodegen.js", "escodegen": "bin/escodegen.js",
@ -8802,6 +8803,7 @@
"@jest/types": "^24.9.0", "@jest/types": "^24.9.0",
"anymatch": "^2.0.0", "anymatch": "^2.0.0",
"fb-watchman": "^2.0.0", "fb-watchman": "^2.0.0",
"fsevents": "^1.2.7",
"graceful-fs": "^4.1.15", "graceful-fs": "^4.1.15",
"invariant": "^2.2.4", "invariant": "^2.2.4",
"jest-serializer": "^24.9.0", "jest-serializer": "^24.9.0",
@ -9365,6 +9367,9 @@
"version": "4.0.0", "version": "4.0.0",
"resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz", "resolved": "https://registry.npmjs.org/jsonfile/-/jsonfile-4.0.0.tgz",
"integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=",
"dependencies": {
"graceful-fs": "^4.1.6"
},
"optionalDependencies": { "optionalDependencies": {
"graceful-fs": "^4.1.6" "graceful-fs": "^4.1.6"
} }
@ -12995,6 +13000,7 @@
"eslint-plugin-react-hooks": "^1.6.1", "eslint-plugin-react-hooks": "^1.6.1",
"file-loader": "4.3.0", "file-loader": "4.3.0",
"fs-extra": "^8.1.0", "fs-extra": "^8.1.0",
"fsevents": "2.1.2",
"html-webpack-plugin": "4.0.0-beta.11", "html-webpack-plugin": "4.0.0-beta.11",
"identity-obj-proxy": "3.0.0", "identity-obj-proxy": "3.0.0",
"jest": "24.9.0", "jest": "24.9.0",
@ -15849,8 +15855,10 @@
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.4.tgz", "resolved": "https://registry.npmjs.org/watchpack/-/watchpack-1.7.4.tgz",
"integrity": "sha512-aWAgTW4MoSJzZPAicljkO1hsi1oKj/RRq/OJQh2PKI2UKL04c2Bs+MBOB+BBABHTXJpf9mCwHN7ANCvYsvY2sg==", "integrity": "sha512-aWAgTW4MoSJzZPAicljkO1hsi1oKj/RRq/OJQh2PKI2UKL04c2Bs+MBOB+BBABHTXJpf9mCwHN7ANCvYsvY2sg==",
"dependencies": { "dependencies": {
"chokidar": "^3.4.1",
"graceful-fs": "^4.1.2", "graceful-fs": "^4.1.2",
"neo-async": "^2.5.0" "neo-async": "^2.5.0",
"watchpack-chokidar2": "^2.0.0"
}, },
"optionalDependencies": { "optionalDependencies": {
"chokidar": "^3.4.1", "chokidar": "^3.4.1",
@ -15888,6 +15896,7 @@
"anymatch": "^2.0.0", "anymatch": "^2.0.0",
"async-each": "^1.0.1", "async-each": "^1.0.1",
"braces": "^2.3.2", "braces": "^2.3.2",
"fsevents": "^1.2.7",
"glob-parent": "^3.1.0", "glob-parent": "^3.1.0",
"inherits": "^2.0.3", "inherits": "^2.0.3",
"is-binary-path": "^1.0.0", "is-binary-path": "^1.0.0",
@ -16150,6 +16159,7 @@
"anymatch": "^2.0.0", "anymatch": "^2.0.0",
"async-each": "^1.0.1", "async-each": "^1.0.1",
"braces": "^2.3.2", "braces": "^2.3.2",
"fsevents": "^1.2.7",
"glob-parent": "^3.1.0", "glob-parent": "^3.1.0",
"inherits": "^2.0.3", "inherits": "^2.0.3",
"is-binary-path": "^1.0.0", "is-binary-path": "^1.0.0",

View File

@ -1,6 +1,6 @@
{ {
"name": "reddit-slideshow", "name": "reddit-slideshow",
"version": "0.1.5", "version": "0.1.6",
"private": true, "private": true,
"dependencies": { "dependencies": {
"axios": "^0.19.2", "axios": "^0.19.2",

View File

@ -95,6 +95,18 @@ const layout = (props) => {
<label htmlFor="hideUI">Hide UI</label> <label htmlFor="hideUI">Hide UI</label>
</div> </div>
</div> </div>
<div className="infoRow">
<div className="infoElement">
<input
type="checkbox"
id="sound"
name="sound"
onChange={props.soundCheckboxHandler}
checked={props.sound}
/>
<label htmlFor="sound">Sound</label>
</div>
</div>
</div> </div>
{props.showInfo ? ( {props.showInfo ? (
<LeftArrowSVG <LeftArrowSVG
@ -128,6 +140,7 @@ const layout = (props) => {
classes={slideClasses.concat(["current"])} classes={slideClasses.concat(["current"])}
key={id} key={id}
currentEndedPLaying={currentEndedPlayingHandler} currentEndedPLaying={currentEndedPlayingHandler}
sound={props.sound}
/> />
) : null} ) : null}
{props.prev !== props.post ? ( {props.prev !== props.post ? (

View File

@ -25,13 +25,13 @@ const Slide = (props) => {
// Imgur videos can be linked by using .mp4 extension instead of .gifv // Imgur videos can be linked by using .mp4 extension instead of .gifv
if (fileExt === ".gifv") { if (fileExt === ".gifv") {
return ( return (
<video autoPlay loop muted className={props.classes.join(" ") + " video"} onPlaying={endedHandler}> <video autoPlay loop muted={!props.sound} className={props.classes.join(" ") + " video"} onPlaying={endedHandler}>
<source src={props.url.replace(".gifv", ".mp4")} type="video/mp4" /> <source src={props.url.replace(".gifv", ".mp4")} type="video/mp4" />
</video> </video>
); );
} else if (fileExt === ".mp4") { } else if (fileExt === ".mp4") {
return ( return (
<video autoPlay loop muted className={props.classes.join(" ") + " video"} onPlaying={endedHandler}> <video autoPlay loop muted={!props.sound} className={props.classes.join(" ") + " video"} onPlaying={endedHandler}>
<source src={props.url.replace(".mp4", ".webm")} type="video/webm" /> <source src={props.url.replace(".mp4", ".webm")} type="video/webm" />
<source src={props.url} type="video/mp4" /> <source src={props.url} type="video/mp4" />
</video> </video>

View File

@ -18,6 +18,7 @@ class App extends Component {
showTitle: true, // show image title at top left showTitle: true, // show image title at top left
showInfo: true, // show info and buttons at bottom right showInfo: true, // show info and buttons at bottom right
auto: false, // autoplay auto: false, // autoplay
sound: false,
hideUI: this.hideUI, hideUI: this.hideUI,
hideUIChecked: this.hideUI, hideUIChecked: this.hideUI,
showNSWF: true, showNSWF: true,
@ -322,6 +323,19 @@ class App extends Component {
} }
}; };
/**
* Handle sound checkbox.
*/
soundCheckboxHandler = (event) => {
if (event.target.checked) {
this.setState({
sound: true
});
} else {
this.setState({ sound: false });
}
};
/** /**
* Handle hideUI checkbox. * Handle hideUI checkbox.
*/ */
@ -409,6 +423,8 @@ class App extends Component {
infoClick={this.toggleInfoHandler} infoClick={this.toggleInfoHandler}
autoPlay={this.state.auto} autoPlay={this.state.auto}
autoCheckboxHandler={this.autoCheckboxHandler} autoCheckboxHandler={this.autoCheckboxHandler}
sound={this.state.sound}
soundCheckboxHandler={this.soundCheckboxHandler}
hideUI={this.state.hideUI} hideUI={this.state.hideUI}
hideUIChecked={this.state.hideUIChecked} hideUIChecked={this.state.hideUIChecked}
hideUICheckboxHandler={this.hideUICheckboxHandler} hideUICheckboxHandler={this.hideUICheckboxHandler}