New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API docs for arcade.sound.play_sound says its only tested on Py2.7 #180

Closed
viblo opened this Issue Mar 5, 2018 · 5 comments

Comments

3 participants
@viblo

viblo commented Mar 5, 2018

I noticed that the api docs for arcade.sound.play_sound says its only tested on Python 2.7, but Arcade itself doesnt support Python 2.7. Maybe the text can be updated in case it actually is tested on Python 3?
http://arcade.academy/arcade.html#arcade.sound.play_sound

@pvcraven pvcraven added the bug label Mar 5, 2018

@pvcraven pvcraven self-assigned this Mar 5, 2018

@pvcraven

This comment has been minimized.

Owner

pvcraven commented Mar 5, 2018

Thanks, I'll update. Those are the original comments from where I got the sound library from, and they don't make sense here. Irritatingly, it still doesn't seem to work on any Mac I've seen, except the one I originally tried it on.

@dlanghorne0428

This comment has been minimized.

Contributor

dlanghorne0428 commented Mar 16, 2018

I thought I would share some interesting behavior with the Arcade Sound Module running the sprite_bullets example on my Mac (MacOS 10.12.6 Sierra, python 3.6.2, and arcade 1.3.0)

The sound works when I run the example from the command line
python -m arcade.examples.sprite_bullets

The sound also works when I run the program from the example directory
$ cd /Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/arcade/examples/
$ python3 sprite_bullets.py

However, when I copy the example and associated image and sound files to my Users folder, an OSError is generated: OSError: Unable to load sound named:

Using the Wing IDE debugger, it appears that this line doesn't set the url variable correctly. Even though the pathname in the sound variable is correct, the URLWithString method returns None.
url = NSURL.URLWithString_(sound)

@dlanghorne0428

This comment has been minimized.

Contributor

dlanghorne0428 commented Mar 17, 2018

This may be a solution for playing sound files on the Mac. Changing the URL method seems to work for local sound files. Tested on MacOS 10.12 Sierra and 10.13 High Sierra.
def _playsoundOSX(sound):

    if '://' in sound:
        url   = NSURL.URLWithString_(sound)     # don't think this works
    else:
        if not sound.startswith('/'):
            from os import getcwd
            sound = getcwd() + '/' + sound
        url = NSURL.fileURLWithPath_(sound)    # this seems to work
        
    nssound = NSSound.alloc().initWithContentsOfURL_byReference_(url, True)
@pvcraven

This comment has been minimized.

Owner

pvcraven commented Mar 18, 2018

Hm, reliable sound has always been the biggest headache for my on Python. I'll have to give this a shot.

pvcraven added a commit that referenced this issue Apr 1, 2018

Issue #184, get sound hopefully working on the Mac.
Related to #180, using code from dlanghorne0428.

@pvcraven pvcraven added this to the 1.3.4 milestone May 20, 2018

@pvcraven pvcraven added this to Done in Release 1.3.4 May 20, 2018

@pvcraven

This comment has been minimized.

Owner

pvcraven commented May 28, 2018

Closed with release of 1.3.4 on 28-May-2018.

@pvcraven pvcraven closed this May 28, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment