improve a little bit livestream player

This commit is contained in:
SrGooglo 2025-04-02 01:51:41 +00:00
parent c3d99e0d83
commit c9e222d686
2 changed files with 288 additions and 295 deletions

View File

@ -139,12 +139,10 @@ export default class StreamViewer extends React.Component {
} }
loadStream = async (stream_id) => { loadStream = async (stream_id) => {
let stream = await SpectrumModel.getLivestream(stream_id).catch( let stream = await SpectrumModel.getStream(stream_id).catch((error) => {
(error) => {
console.error(error) console.error(error)
return null return null
}, })
)
if (!stream) { if (!stream) {
return false return false
@ -169,8 +167,6 @@ export default class StreamViewer extends React.Component {
this.state.decoderInstance.destroy() this.state.decoderInstance.destroy()
} }
this.state.player.destroy()
this.setState({ this.setState({
isEnded: true, isEnded: true,
loading: false, loading: false,
@ -221,15 +217,10 @@ export default class StreamViewer extends React.Component {
componentDidMount = async () => { componentDidMount = async () => {
this.enterPlayerAnimation() this.enterPlayerAnimation()
const stream_id = this.props.params.id
console.log("Stream ID >", stream_id)
this.attachPlayer() this.attachPlayer()
// get stream info // load stream
const stream = await this.loadStream(stream_id) const stream = await this.loadStream(this.props.params.id)
if (!stream) { if (!stream) {
return this.onSourceEnd() return this.onSourceEnd()
@ -254,16 +245,15 @@ export default class StreamViewer extends React.Component {
} }
componentWillUnmount = () => { componentWillUnmount = () => {
if (this.state.player) {
this.state.player.destroy()
}
if (typeof this.state.decoderInstance?.unload === "function") { if (typeof this.state.decoderInstance?.unload === "function") {
this.state.decoderInstance.unload() this.state.decoderInstance.unload()
} }
this.exitPlayerAnimation() if (typeof this.state.decoderInstance?.destroy === "function") {
this.state.decoderInstance.destroy()
}
this.exitPlayerAnimation()
this.toggleCinemaMode(false) this.toggleCinemaMode(false)
if (this.streamInfoInterval) { if (this.streamInfoInterval) {
@ -272,17 +262,21 @@ export default class StreamViewer extends React.Component {
} }
enterPlayerAnimation = () => { enterPlayerAnimation = () => {
app.cores.style.applyTemporalVariant("dark")
app.layout.toggleCompactMode(true)
app.layout.toggleCenteredContent(false) app.layout.toggleCenteredContent(false)
app.controls.toggleUIVisibility(false) app.layout.toggleTotalWindowHeight(true)
if (app.layout.tools_bar) {
app.layout.tools_bar.toggleVisibility(false)
}
} }
exitPlayerAnimation = () => { exitPlayerAnimation = () => {
app.cores.style.applyVariant(app.cores.style.currentVariantKey)
app.layout.toggleCompactMode(false)
app.layout.toggleCenteredContent(true) app.layout.toggleCenteredContent(true)
app.controls.toggleUIVisibility(true) app.layout.toggleTotalWindowHeight(false)
if (app.layout.tools_bar) {
app.layout.tools_bar.toggleVisibility(true)
}
} }
updateQuality = (newQuality) => { updateQuality = (newQuality) => {
@ -308,6 +302,9 @@ export default class StreamViewer extends React.Component {
to = !this.state.cinemaMode to = !this.state.cinemaMode
} }
app.controls.toggleUIVisibility(!to)
app.layout.toggleCompactMode(to)
this.setState({ cinemaMode: to }) this.setState({ cinemaMode: to })
} }
@ -318,21 +315,14 @@ export default class StreamViewer extends React.Component {
["cinemaMode"]: this.state.cinemaMode, ["cinemaMode"]: this.state.cinemaMode,
})} })}
> >
{this.props.query.id}
<div className="livestream_player"> <div className="livestream_player">
<div className="livestream_player_header"> <div className="livestream_player_header">
<div
className="livestream_player_header_exit"
onClick={() => app.location.back()}
>
<Icons.IoMdExit />
</div>
{this.state.stream ? ( {this.state.stream ? (
<> <>
<div className="livestream_player_header_user"> <div className="livestream_player_header_user">
<UserPreview <UserPreview
user={this.state.stream.user} user_id={this.state.stream.user_id}
onlyIcon
/> />
<div className="livestream_player_indicators"> <div className="livestream_player_indicators">
@ -350,24 +340,19 @@ export default class StreamViewer extends React.Component {
{this.state.stream.info && ( {this.state.stream.info && (
<div className="livestream_player_header_info"> <div className="livestream_player_header_info">
<div className="livestream_player_header_info_title"> <div className="livestream_player_header_title">
<h1> <h1>
{this.state.stream.info?.title} {this.state.stream.info?.title}
</h1> </h1>
</div> </div>
<div className="livestream_player_header_info_description"> <div className="livestream_player_header_description">
<Marquee mode="smooth"> <Marquee mode="smooth">
{({ index }) => {
return (
<h4> <h4>
{ {
this.state this.state.stream.info
.stream.info
?.description ?.description
} }
</h4> </h4>
)
}}
</Marquee> </Marquee>
</div> </div>
</div> </div>

View File

@ -1,6 +1,9 @@
@panel-width: 500px;
@chatbox-header-height: 50px; @chatbox-header-height: 50px;
.content_layout {
padding: 10px;
}
html { html {
&.mobile { &.mobile {
.livestream { .livestream {
@ -41,13 +44,15 @@ html {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
height: 100vh; gap: 10px;
height: 100%;
width: 100%; width: 100%;
overflow: hidden;
color: var(--background-color-contrast); color: var(--background-color-contrast);
overflow: hidden;
h1, h1,
h2, h2,
h3, h3,
@ -60,15 +65,7 @@ html {
&.cinemaMode { &.cinemaMode {
.livestream_player { .livestream_player {
width: 100vw; border-radius: 0px;
video {
width: 100vw;
}
.plyr {
width: 100vw;
}
.livestream_player_header { .livestream_player_header {
animation: disappear 0.3s ease-in-out forwards; animation: disappear 0.3s ease-in-out forwards;
@ -87,7 +84,7 @@ html {
padding: 20px; padding: 20px;
overflow-x: hidden; background-color: transparent;
.chatbox { .chatbox {
padding: 0; padding: 0;
@ -116,13 +113,15 @@ html {
align-items: center; align-items: center;
justify-content: center; justify-content: center;
width: calc(100% - @panel-width); width: 100%;
height: 100%; height: 100%;
overflow-y: hidden; overflow-y: hidden;
transition: all 0.3s ease-in-out; transition: all 0.3s ease-in-out;
border-radius: 24px;
.livestream_player_loading { .livestream_player_loading {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -190,19 +189,6 @@ html {
white-space: nowrap; white-space: nowrap;
} }
.livestream_player_header_exit {
display: flex;
flex-direction: row;
width: fit-content;
height: fit-content;
svg {
font-size: 1.5rem;
margin: 0;
}
}
.livestream_player_header_user { .livestream_player_header_user {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -222,6 +208,12 @@ html {
height: fit-content; height: fit-content;
.ant-tag { .ant-tag {
display: flex;
flex-direction: row;
align-items: center;
gap: 5px;
background-color: #eb0400; background-color: #eb0400;
border-color: #eb0400; border-color: #eb0400;
color: var(--background-color-contrast); color: var(--background-color-contrast);
@ -247,11 +239,12 @@ html {
overflow: hidden; overflow: hidden;
min-width: 350px;
width: 100%; width: 100%;
.livestream_player_header_title { .livestream_player_header_title {
font-family: "Space Grotesk", sans-serif; font-family: "Space Grotesk", sans-serif;
font-size: 1rem; font-size: 0.9rem;
font-weight: 700; font-weight: 700;
text-overflow: ellipsis; text-overflow: ellipsis;
@ -272,13 +265,20 @@ html {
} }
.livestream_panel { .livestream_panel {
position: relative;
z-index: 100;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
position: relative; height: 100%;
height: 100vh; min-width: 300px;
width: 30%;
width: @panel-width; background-color: var(--background-color-accent);
border-radius: 24px;
overflow: hidden;
.chatbox { .chatbox {
position: relative; position: relative;
@ -288,7 +288,7 @@ html {
overflow: hidden; overflow: hidden;
padding: 20px; padding: 10px;
.chatbox_header { .chatbox_header {
position: absolute; position: absolute;
@ -327,18 +327,26 @@ html {
height: @chatbox-header-height; height: @chatbox-header-height;
filter: blur(7px); filter: blur(7px);
background-color: rgba(var(--layoutBackgroundColor), 0.7); background-color: rgba(
var(--layoutBackgroundColor),
0.7
);
} }
padding-top: @chatbox-header-height; padding-top: @chatbox-header-height;
} }
.liveChat_textInput {
.ant-input-affix-wrapper {
background-color: var(--background-color-primary);
}
}
} }
} }
} }
.plyr { .plyr {
border-radius: 0 4px 4px 0; width: 100%;
width: 80vw; height: 100%;
height: 100vh;
} }
} }