简体   繁体   中英

Is there a way to get audio file length Python Pyglet

I am working with pyglet and was wondering if there was a way to get full audio file length? The only way of getting the time that I am aware of is the player.time function.

Code:

import pyglet

player = pyglet.media.Player()
sound = pyglet.media.load("My Movie.wav", streaming=False)
player.queue(sound)
player.play()

You can use the .duration property :

sound.duration

The length of the source, in seconds.

Not all source durations can be determined; in this case the value is None.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM