Skip to content

Commit

Permalink
Call playbackposition on demand
Browse files Browse the repository at this point in the history
  • Loading branch information
fakelag committed Mar 23, 2024
1 parent 8ce26a1 commit fdaf512
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions discordplayer/voiceworker.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/fakelag/streaming-music-bot/entities"

"github.com/fakelag/dca"
// . "github.com/onsi/ginkgo/v2"
)

type DcaMediaSession struct {
Expand Down Expand Up @@ -134,7 +135,6 @@ func (dms *DiscordMusicSession) playMediaFile(

select {
case err = <-session.done:
playbackPosition := session.streamingSession.PlaybackPosition()
dms.cleanupEncodingAndVoiceSession(session.encodingSession, dms.voiceConnection)

if err == nil || err == io.EOF {
Expand All @@ -149,7 +149,7 @@ func (dms *DiscordMusicSession) playMediaFile(
mediaFileDuration := mediaFile.Duration()

if mediaFileDuration != nil {
mediaDurationLeft := *mediaFileDuration - playbackPosition
mediaDurationLeft := *mediaFileDuration - session.streamingSession.PlaybackPosition()

if mediaDurationLeft.Seconds() < 2 {
// No more content to play, done
Expand All @@ -160,7 +160,7 @@ func (dms *DiscordMusicSession) playMediaFile(
keepPlayingCurrentMedia = true

if mediaFile.CanJumpToTimeStamp() {
keepPlayingCurrentMediaFrom = playbackPosition
keepPlayingCurrentMediaFrom = session.streamingSession.PlaybackPosition()
}

return
Expand Down

0 comments on commit fdaf512

Please sign in to comment.