diff --git a/packages/app/src/components/Player/BackgroundMediaPlayer/index.jsx b/packages/app/src/components/Player/BackgroundMediaPlayer/index.jsx
index bb149143..9e5d8b04 100644
--- a/packages/app/src/components/Player/BackgroundMediaPlayer/index.jsx
+++ b/packages/app/src/components/Player/BackgroundMediaPlayer/index.jsx
@@ -1,9 +1,12 @@
import React from "react"
import * as antd from "antd"
import classnames from "classnames"
-import { Icons } from "components/Icons"
import Marquee from "react-fast-marquee"
+import { Icons } from "components/Icons"
+
+import { WithPlayerContext, Context } from "contexts/WithPlayerContext"
+
import "./index.less"
function RGBStringToValues(rgbString) {
@@ -16,30 +19,22 @@ function RGBStringToValues(rgbString) {
return [rgb[0], rgb[1], rgb[2]]
}
-export default class BackgroundMediaPlayer extends React.Component {
+export default (props) => {
+ return
+
+
+}
+
+export class BackgroundMediaPlayer extends React.Component {
+ static contextType = Context
+
state = {
- thumbnailAnalysis: app.cores.player.getState("coverColorAnalysis"),
- currentPlaying: app.cores.player.getState("currentAudioManifest"),
- plabackState: app.cores.player.getState("playbackStatus") ?? "stopped",
expanded: false,
}
events = {
- "player.coverColorAnalysis.update": (data) => {
- this.setState({
- thumbnailAnalysis: data
- })
- },
- "player.current.update": (data) => {
- this.setState({
- currentPlaying: data
- })
- },
- "player.status.update": (data) => {
- this.setState({
- plabackState: data
- })
- },
"sidebar.expanded": (to) => {
if (!to) {
this.toogleExpand(false)
@@ -78,19 +73,19 @@ export default class BackgroundMediaPlayer extends React.Component {
className={classnames(
"background_media_player",
{
- ["lightBackground"]: this.state.thumbnailAnalysis?.isLight,
+ ["lightBackground"]: this.context.coverColorAnalysis?.isLight,
["expanded"]: this.state.expanded,
}
)}
style={{
- backgroundColor: this.state.thumbnailAnalysis?.rgba,
- "--averageColorValues": this.state.thumbnailAnalysis?.rgba,
+ backgroundColor: this.context.coverColorAnalysis?.rgba,
+ "--averageColorValues": this.context.coverColorAnalysis?.rgba,
}}
>
@@ -103,12 +98,12 @@ export default class BackgroundMediaPlayer extends React.Component {
className={classnames(
"background_media_player__icon",
{
- ["bounce"]: this.state.plabackState === "playing",
+ ["bounce"]: this.context.playbackStatus === "playing",
}
)}
>
{
- this.state.plabackState === "playing" ? :
+ this.context.playbackStatus === "playing" ? :
}
@@ -120,12 +115,12 @@ export default class BackgroundMediaPlayer extends React.Component {
!this.state.expanded &&