react-audio-play
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -1,5 +0,2 @@ | ||
declare type Props = { | ||
style?: {}; | ||
}; | ||
export declare const AudioPlayer: (props: Props) => JSX.Element; | ||
export {}; | ||
import { AudioTypeInterface } from './AudioTypeInterface'; | ||
export declare const AudioPlayer: (props: AudioTypeInterface) => JSX.Element; |
@@ -8,6 +8,19 @@ "use strict"; | ||
const react_1 = __importDefault(require("react")); | ||
const react_2 = require("react"); | ||
const AudioLibrary_1 = require("./AudioLibrary"); | ||
const AudioPlayer = (props) => { | ||
return react_1.default.createElement("div", null, "AudioPlayer"); | ||
const audio = (0, react_2.useRef)(new AudioLibrary_1.AudioLibrary(props)); | ||
const [isPlaying, setIsPlaying] = (0, react_2.useState)(false); | ||
const playOrStop = () => { | ||
setIsPlaying(!isPlaying); | ||
if (isPlaying) { | ||
audio.current.stop(); | ||
} | ||
else { | ||
audio.current.play(); | ||
} | ||
}; | ||
return react_1.default.createElement("button", { onClick: playOrStop }, isPlaying ? 'Stop' : 'Play'); | ||
}; | ||
exports.AudioPlayer = AudioPlayer; | ||
//# sourceMappingURL=AudioPlayer.js.map |
@@ -1,5 +0,2 @@ | ||
declare type Props = { | ||
style?: {}; | ||
}; | ||
export declare const AudioPlayer: (props: Props) => JSX.Element; | ||
export {}; | ||
import { AudioTypeInterface } from './AudioTypeInterface'; | ||
export declare const AudioPlayer: (props: AudioTypeInterface) => JSX.Element; |
import React from 'react'; | ||
import { useRef, useState } from 'react'; | ||
import { AudioLibrary } from './AudioLibrary'; | ||
export const AudioPlayer = (props) => { | ||
return React.createElement("div", null, "AudioPlayer"); | ||
const audio = useRef(new AudioLibrary(props)); | ||
const [isPlaying, setIsPlaying] = useState(false); | ||
const playOrStop = () => { | ||
setIsPlaying(!isPlaying); | ||
if (isPlaying) { | ||
audio.current.stop(); | ||
} | ||
else { | ||
audio.current.play(); | ||
} | ||
}; | ||
return React.createElement("button", { onClick: playOrStop }, isPlaying ? 'Stop' : 'Play'); | ||
}; | ||
//# sourceMappingURL=AudioPlayer.js.map |
{ | ||
"name": "react-audio-play", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "React audio player component", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
9262
32
136
0