mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-10 19:14:16 +00:00
added plyr options
This commit is contained in:
parent
12f2b9be67
commit
0a3eb7eba0
@ -25,7 +25,7 @@ export default class StreamViewer extends React.Component {
|
|||||||
streamSource: null,
|
streamSource: null,
|
||||||
loadedProtocol: "flv",
|
loadedProtocol: "flv",
|
||||||
protocolInstance: null,
|
protocolInstance: null,
|
||||||
defaultOptions: undefined,
|
plyrOptions: {},
|
||||||
}
|
}
|
||||||
|
|
||||||
videoPlayerRef = React.createRef()
|
videoPlayerRef = React.createRef()
|
||||||
@ -43,6 +43,7 @@ export default class StreamViewer extends React.Component {
|
|||||||
const player = new Plyr("#player", {
|
const player = new Plyr("#player", {
|
||||||
autoplay: true,
|
autoplay: true,
|
||||||
controls: ["play", "mute", "volume", "fullscreen", "options", "settings"],
|
controls: ["play", "mute", "volume", "fullscreen", "options", "settings"],
|
||||||
|
...this.state.plyrOptions,
|
||||||
})
|
})
|
||||||
|
|
||||||
await this.setState({
|
await this.setState({
|
||||||
@ -158,12 +159,39 @@ export default class StreamViewer extends React.Component {
|
|||||||
|
|
||||||
loadWithProtocol = {
|
loadWithProtocol = {
|
||||||
hls: () => {
|
hls: () => {
|
||||||
const source = `${streamsSource}/stream/hls/${this.state.streamKey}`
|
const source = `${streamsSource}/media/${this.state.streamKey}/index.m3u8`
|
||||||
const hls = new Hls()
|
const hls = new Hls()
|
||||||
|
|
||||||
hls.loadSource(source)
|
hls.loadSource(source)
|
||||||
hls.attachMedia(this.videoPlayerRef.current)
|
hls.attachMedia(this.videoPlayerRef.current)
|
||||||
|
|
||||||
|
hls.on(Hls.Events.MANIFEST_PARSED, () => {
|
||||||
|
const levels = hls.levels
|
||||||
|
|
||||||
|
const quality = {
|
||||||
|
default: levels[levels.length - 1].height,
|
||||||
|
options: levels.map((level) => level.height),
|
||||||
|
forced: true,
|
||||||
|
onChange: (newQuality) => {
|
||||||
|
console.log('changes', newQuality)
|
||||||
|
|
||||||
|
levels.forEach((level, levelIndex) => {
|
||||||
|
if (level.height === newQuality) {
|
||||||
|
hls.currentLevel = levelIndex
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
plyrOptions: {
|
||||||
|
quality,
|
||||||
|
...this.state.plyrOptions
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
this.setState({ protocolInstance: hls, loadedProtocol: "hls" })
|
this.setState({ protocolInstance: hls, loadedProtocol: "hls" })
|
||||||
},
|
},
|
||||||
flv: () => {
|
flv: () => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user