mirror of
https://github.com/ragestudio/comty.git
synced 2025-06-11 03:24:16 +00:00
fix minimized mode
This commit is contained in:
parent
7d7c6c84bc
commit
6e469fadca
@ -2,6 +2,8 @@ import React from "react"
|
|||||||
import Core from "evite/src/core"
|
import Core from "evite/src/core"
|
||||||
import { Observable } from "object-observer"
|
import { Observable } from "object-observer"
|
||||||
import store from "store"
|
import store from "store"
|
||||||
|
import { FastAverageColor } from "fast-average-color"
|
||||||
|
|
||||||
// import { createRealTimeBpmProcessor } from "realtime-bpm-analyzer"
|
// import { createRealTimeBpmProcessor } from "realtime-bpm-analyzer"
|
||||||
|
|
||||||
import EmbbededMediaPlayer from "components/EmbbededMediaPlayer"
|
import EmbbededMediaPlayer from "components/EmbbededMediaPlayer"
|
||||||
@ -49,6 +51,8 @@ export default class Player extends Core {
|
|||||||
|
|
||||||
currentAudioInstance = null
|
currentAudioInstance = null
|
||||||
|
|
||||||
|
fac = new FastAverageColor()
|
||||||
|
|
||||||
state = Observable.from({
|
state = Observable.from({
|
||||||
loading: false,
|
loading: false,
|
||||||
minimized: false,
|
minimized: false,
|
||||||
@ -57,6 +61,7 @@ export default class Player extends Core {
|
|||||||
audioVolume: AudioPlayerStorage.get("volume") ?? 0.3,
|
audioVolume: AudioPlayerStorage.get("volume") ?? 0.3,
|
||||||
velocity: AudioPlayerStorage.get("velocity") ?? 1,
|
velocity: AudioPlayerStorage.get("velocity") ?? 1,
|
||||||
|
|
||||||
|
coverColorAnalysis: null,
|
||||||
currentAudioManifest: null,
|
currentAudioManifest: null,
|
||||||
playbackStatus: "stopped",
|
playbackStatus: "stopped",
|
||||||
crossfading: false,
|
crossfading: false,
|
||||||
@ -143,6 +148,7 @@ export default class Player extends Core {
|
|||||||
seek: this.seek.bind(this),
|
seek: this.seek.bind(this),
|
||||||
duration: this.duration.bind(this),
|
duration: this.duration.bind(this),
|
||||||
velocity: this.velocity.bind(this),
|
velocity: this.velocity.bind(this),
|
||||||
|
close: this.close.bind(this),
|
||||||
}
|
}
|
||||||
|
|
||||||
async onInitialize() {
|
async onInitialize() {
|
||||||
@ -175,6 +181,25 @@ export default class Player extends Core {
|
|||||||
case "currentAudioManifest": {
|
case "currentAudioManifest": {
|
||||||
app.eventBus.emit("player.current.update", change.object.currentAudioManifest)
|
app.eventBus.emit("player.current.update", change.object.currentAudioManifest)
|
||||||
|
|
||||||
|
if (change.object.currentAudioManifest) {
|
||||||
|
// analyze cover color
|
||||||
|
|
||||||
|
if (change.object.currentAudioManifest.thumbnail) {
|
||||||
|
this.fac.getColorAsync(change.object.currentAudioManifest.thumbnail)
|
||||||
|
.then((color) => {
|
||||||
|
this.state.coverColorAnalysis = color
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
console.error(err)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break
|
||||||
|
}
|
||||||
|
case "coverColorAnalysis": {
|
||||||
|
app.eventBus.emit("player.coverColorAnalysis.update", change.object.coverColorAnalysis)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
case "audioMuted": {
|
case "audioMuted": {
|
||||||
@ -214,9 +239,11 @@ export default class Player extends Core {
|
|||||||
}
|
}
|
||||||
case "minimized": {
|
case "minimized": {
|
||||||
if (change.object.minimized) {
|
if (change.object.minimized) {
|
||||||
app.SidebarController.setBackgroundItem(React.createElement(BackgroundMediaPlayer))
|
app.SidebarController.attachBottomItem("player", BackgroundMediaPlayer, {
|
||||||
|
noContainer: true
|
||||||
|
})
|
||||||
} else {
|
} else {
|
||||||
app.SidebarController.setBackgroundItem(null)
|
app.SidebarController.removeBottomItem("player")
|
||||||
}
|
}
|
||||||
|
|
||||||
app.eventBus.emit("player.minimized.update", change.object.minimized)
|
app.eventBus.emit("player.minimized.update", change.object.minimized)
|
||||||
@ -268,7 +295,7 @@ export default class Player extends Core {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currentDomWindow.close()
|
this.currentDomWindow.destroy()
|
||||||
this.currentDomWindow = null
|
this.currentDomWindow = null
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -514,6 +541,8 @@ export default class Player extends Core {
|
|||||||
this.currentAudioInstance.track.connect(filter).connect(this.realtimeAnalyzerNode)
|
this.currentAudioInstance.track.connect(filter).connect(this.realtimeAnalyzerNode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
instance.audioElement.muted = this.state.audioMuted
|
||||||
|
|
||||||
instance.audioElement.play()
|
instance.audioElement.play()
|
||||||
|
|
||||||
// check if the audio is a live stream when metadata is loaded
|
// check if the audio is a live stream when metadata is loaded
|
||||||
@ -667,6 +696,11 @@ export default class Player extends Core {
|
|||||||
this.audioQueue = []
|
this.audioQueue = []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
close() {
|
||||||
|
this.stop()
|
||||||
|
this.detachPlayerComponent()
|
||||||
|
}
|
||||||
|
|
||||||
toogleMute(to) {
|
toogleMute(to) {
|
||||||
this.state.audioMuted = to ?? !this.state.audioMuted
|
this.state.audioMuted = to ?? !this.state.audioMuted
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user