简体   繁体   中英

Audio using PyGame Subset for Android

I am trying to play a simple wav file using PyGame Subset for Android. I can't seem to get it working. Does anyone have any example code working? There isn't any examples in the documentation.

According to Pygame Subset for Android documentation, you should be able to play sounds using android_mixer . Start by importing it [1] :

import android_mixer as mixer

Now use the mixer just as a common pygame mixer to play sounds:

mixer.music.load(sys.argv[1])
mixer.music.play()

Please note that "the init and pre_init methods work, but are ignored - Android chooses appropriate settign automatically" as well as that "Only filenames and true file objects can be used - file-like objects will probably not work". Some other restrictions apply as well. [1] .

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