Skip to content

Commit ef4b669

Browse files
authored
Merge pull request #170 from ragestudio/dev
2 parents d279264 + dc29623 commit ef4b669

File tree

3 files changed

+62
-24
lines changed

3 files changed

+62
-24
lines changed

packages/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@comty/app",
3-
"version": "1.44.1@alpha",
3+
"version": "1.44.2@alpha",
44
"license": "ComtyLicense",
55
"main": "electron/main",
66
"type": "module",

packages/app/src/cores/player/classes/AudioBase.js

Lines changed: 43 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,15 @@ export default class AudioBase {
8181
this.console.timeEnd("instanciate class")
8282
}
8383

84-
if (
85-
manifest.mpd_mode === true &&
86-
!manifest.dash_manifest &&
87-
this.demuxer
88-
) {
84+
if (manifest.mpd_mode === true && !manifest.dash_manifest && this.demuxer) {
8985
this.console.time("fetch")
9086
const manifestString = await fetch(manifest.source).then((res) =>
9187
res.text(),
9288
)
9389
this.console.timeEnd("fetch")
9490

9591
this.console.time("parse mpd")
96-
manifest.dash_manifest = await MPDParser(
97-
manifestString,
98-
manifest.source,
99-
)
92+
manifest.dash_manifest = await MPDParser(manifestString, manifest.source)
10093
this.console.timeEnd("parse mpd")
10194
}
10295

@@ -247,14 +240,51 @@ export default class AudioBase {
247240
streaming: {
248241
//cacheInitSegments: true,
249242
buffer: {
250-
bufferTimeAtTopQuality: 15,
251-
initialBufferLevel: 1,
243+
bufferTimeAtTopQuality: 30,
244+
bufferTimeAtTopQualityLongForm: 60,
245+
bufferTimeDefault: 20,
246+
initialBufferLevel: 5,
247+
bufferToKeep: 10,
248+
longFormContentDurationThreshold: 300,
249+
stallThreshold: 0.5,
250+
bufferPruningInterval: 30,
251+
},
252+
abr: {
253+
initialBitrate: {
254+
audio: 128,
255+
},
256+
rules: {
257+
insufficientBufferRule: {
258+
active: true,
259+
parameters: {
260+
bufferLevel: 0.3,
261+
},
262+
},
263+
switchHistoryRule: {
264+
active: true,
265+
parameters: {
266+
sampleSize: 8,
267+
},
268+
},
269+
},
270+
throughput: {
271+
averageCalculationMode: "slidingWindow",
272+
slidingWindowSize: 20,
273+
ewmaHalfLife: 4,
274+
},
275+
},
276+
retrySettings: {
277+
maxRetries: 5,
278+
retryDelayMs: 1000,
279+
retryBackoffFactor: 2,
280+
},
281+
requests: {
282+
requestTimeout: 30000,
283+
xhrWithCredentials: false,
252284
},
253285
},
254286
})
255287

256-
//this.demuxer.setAutoPlay(false)
257-
258288
// Event listeners
259289
this.demuxer.on(dashjs.MediaPlayer.events.ERROR, (event) => {
260290
console.error("Demuxer error", event)

packages/app/src/pages/lyrics/components/text/index.jsx

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ const LyricsText = React.forwardRef((props, textRef) => {
1010

1111
const { lyrics } = props
1212

13+
const currentTrackId = React.useRef(null)
1314
const [syncInterval, setSyncInterval] = React.useState(null)
1415
const [currentLineIndex, setCurrentLineIndex] = React.useState(0)
1516
const [visible, setVisible] = React.useState(false)
@@ -25,9 +26,7 @@ const LyricsText = React.forwardRef((props, textRef) => {
2526
})
2627

2728
if (lineIndex === -1) {
28-
if (!visible) {
29-
setVisible(false)
30-
}
29+
setVisible(false)
3130

3231
return false
3332
}
@@ -70,8 +69,14 @@ const LyricsText = React.forwardRef((props, textRef) => {
7069

7170
//* Handle when current line index change
7271
React.useEffect(() => {
72+
console.debug("[lyrics] currentLineIndex", currentLineIndex)
73+
7374
if (currentLineIndex === 0) {
7475
setVisible(false)
76+
77+
if (textRef.current) {
78+
textRef.current.scrollTop = 0
79+
}
7580
} else {
7681
setVisible(true)
7782

@@ -87,9 +92,6 @@ const LyricsText = React.forwardRef((props, textRef) => {
8792
behavior: "smooth",
8893
block: "center",
8994
})
90-
} else {
91-
// scroll to top
92-
textRef.current.scrollTop = 0
9395
}
9496
}
9597
}
@@ -102,10 +104,16 @@ const LyricsText = React.forwardRef((props, textRef) => {
102104

103105
//* Handle when manifest object change, reset...
104106
React.useEffect(() => {
105-
setVisible(false)
106-
setCurrentLineIndex(0)
107-
// set scroll top to 0
108-
textRef.current.scrollTop = 0
107+
currentTrackId.current = playerState.track_manifest?.id
108+
109+
if (playerState.track_manifest?.id !== currentTrackId.current) {
110+
setVisible(false)
111+
setCurrentLineIndex(0)
112+
113+
if (textRef.current) {
114+
textRef.current.scrollTop = 0
115+
}
116+
}
109117
}, [playerState.track_manifest])
110118

111119
React.useEffect(() => {

0 commit comments

Comments
 (0)