Re: Audio wrapper for Python

Challenges like this can crop up in any language, its all part of the fun, heh. Part of what I meant is that I don't have the latest version of pygame, so have to rely on the documentation for this. The example I posted was based off that documentation and should function appropriately, from the code you posted it seems you may be calling set_pos incorrectly, as the position in milliseconds has to be inside the brackets. So:

mixer.music.set_pos(1000)

This sets the playback position of the sound to one second. In the example I posted I combined that with get_pos for the current position in milliseconds, so:

mixer.music.set_pos(mixer.music.get_pos()-1000.0)

This gets the current position of the sound and subtracts its position by one second, or adds one second. The only place you might need the total length of the sound is to keep from snapping beyond the end point of the sound, either when moving incrementally to far right or snapping beyond it. So something like this:

length = 1000
snap_to = 32424

if snap_to > length:
    snap_to = length
mixer.music.set_pos(snap_to)
-- 
Audiogames-reflector mailing list
Audiogames-reflector@sabahattin-gucukoglu.com
https://sabahattin-gucukoglu.com/cgi-bin/mailman/listinfo/audiogames-reflector
  • ... AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : visualstudio via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : ambro86 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : Turkce_Rap via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector
    • ... AudioGames . net Forum — Developers room : magurp244 via Audiogames-reflector

Reply via email to