omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


    sound.Player in scene

    Pythonista
    2
    3
    2154
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Serpensine
      Serpensine last edited by

      Is it possible to get a sound.Player to play in a scene? I have tried the following code in the setup method:

      music_player = sound.Player(file_path)
      music_player.play()  
      

      But it does not work. sound.play_effect(file_path) does work though, and both of these work when not presented in a scene. Is there a way to make it work?

      1 Reply Last reply Reply Quote 0
      • omz
        omz last edited by omz

        The problem is probably that music_player is a local variable, and falls out of scope (gets garbage-collected) when the setup method returns. Try self.music_player = ... instead to make it an attribute of the scene.

        1 Reply Last reply Reply Quote 0
        • Serpensine
          Serpensine last edited by

          Ah yes, forgot about that. Works fine now.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors