1

I tried making sound work with SimpleGUICS2Pygame (a pygame port of simplegui from http://www.codeskulptor.org/) but no joy - only silence. I tracked down the source code for the module which has some tests as shown below. Still only silence. For the local sound file I tried with both a .wav and a .ogg in the same folder as the file with the test code.

Any ideas please? I'm on Windows 10, with Python 3.7 and Pygame 1.9.6

#!/usr/bin/env python
# -*- coding: latin-1 -*-

"""
Test play sounds. (June 3, 2015)

Piece of SimpleGUICS2Pygame.
https://bitbucket.org/OPiMedia/simpleguics2pygame

GPLv3 --- Copyright (C) 2015 Olivier Pirson
http://www.opimedia.be/
"""

import time

try:
    import simplegui

    SIMPLEGUICS2PYGAME = False
except ImportError:
    import SimpleGUICS2Pygame.simpleguics2pygame as simplegui

    SIMPLEGUICS2PYGAME = True


TEST = 'test sound'

sound_jump_ogg = simplegui.load_sound('http://commondatastorage.googleapis.com/codeskulptor-assets/jump.ogg')

if SIMPLEGUICS2PYGAME:
    local_sound_chirp_wav = simplegui._load_local_sound('_snd/chirp_1s.wav')


def wait(seconds):
    """
    Wait during `seconds` seconds.

    :param seconds: (int or float) >= 0
    """
    assert isinstance(seconds, int) or isinstance(seconds, float), \
        type(seconds)

    start = time.time()
    while time.time() - start < seconds:
        pass


# Main
wait(1)

print('Play "jump.ogg"')
sound_jump_ogg.play()
wait(1)

if SIMPLEGUICS2PYGAME:
    print('Play local "chirp_1s.wav"')
    local_sound_chirp_wav.play()
    wait(local_sound_chirp_wav._get_length())
Robin Andrews
  • 3,514
  • 11
  • 43
  • 111
  • I'm the author of SimpleGUICS2Pygame. I tried with Python 3.5.3 and Pygame 1.9.6 on GNU/Linux (Debian) and the program run perfectly. Have you a problem only with the local sound or both with local and from web? How do you run your program? From a console or from an IDE? – Olivier Pirson Nov 24 '19 at 18:18
  • @OlivierPirson I've got it working now. I just needed to create a frame. My bad. Nice work, BTW. – Robin Andrews Dec 01 '19 at 09:51

0 Answers0