renpy.music.get_duration() cannot return duration of some BGM

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
User avatar
Li yuanlin
Regular
Posts: 94
Joined: Sat Aug 04, 2018 8:42 pm
Location: Hong Kong
Contact:

renpy.music.get_duration() cannot return duration of some BGM

#1 Post by Li yuanlin »

Code: Select all

def get_audio_duration(channel="music"):
        duration = renpy.music.get_duration(channel)
        return convert_format(int(duration))

    def get_audio_position(channel="music"):
        music_pos = renpy.music.get_pos(channel)
        if music_pos:
            return convert_format(int(music_pos))
        return "0:00"
shown in console:
Attachments
QQ截图20240420154546.png
QQ截图20240420154546.png (37.74 KiB) Viewed 140 times
QQ图片20240420154443.png
QQ图片20240420154443.png (15.54 KiB) Viewed 140 times
stay hungry,stay foolish.

User avatar
Li yuanlin
Regular
Posts: 94
Joined: Sat Aug 04, 2018 8:42 pm
Location: Hong Kong
Contact:

Re: renpy.music.get_duration() cannot return duration of some BGM

#2 Post by Li yuanlin »

anyone here?
stay hungry,stay foolish.

User avatar
m_from_space
Miko-Class Veteran
Posts: 985
Joined: Sun Feb 21, 2021 3:36 am
Contact:

Re: renpy.music.get_duration() cannot return duration of some BGM

#3 Post by m_from_space »

Li yuanlin wrote: Mon Apr 22, 2024 5:41 am anyone here?
renpy.music.get_duration()

"Returns 0.0 if no file is playing on channel, or the duration is unknown. Some formats - notably MP3 - do not include duration information in a format Ren'Py can access."

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]