original_docstring: Plays the requested music type/mode.
  
          For most cases, setmusic() is the proper call to use, which itself
          calls this. Certain cases, however, such as soundtrack testing, may
          require calling this directly.
          
docstring: Plays the requested music type/mode.
  For most cases, setmusic() is the proper call to use, which itself
  calls this. Certain cases, however, such as soundtrack testing, may
  require calling this directly.
docstring_tokens: Plays the requested music type / mode . For most cases setmusic () is the proper call to use which itself calls this . Certain cases however such as soundtrack testing may require calling this directly .
code: def do_play_music(self,
                        musictype: Union[MusicType, str, None],
                        continuous: bool = False,
                        mode: MusicPlayMode = MusicPlayMode.REGULAR,
                        testsoundtrack: dict[str, Any] = None) -> None:
          """Plays the requested music type/mode.
  
          For most cases, setmusic() is the proper call to use, which itself
          calls this. Certain cases, however, such as soundtrack testing, may
          require calling this directly.
          """
  
          # We can be passed a MusicType or the string value corresponding
          # to one.
          if musictype is not None:
              try:
                  musictype = MusicType(musictype)
              except ValueError:
                  print(f"Invalid music type: '{musictype}'")
                  musictype = None
  
          with _ba.Context('ui'):
  
              # If they don't want to restart music and we're already
              # playing what's requested, we're done.
              if continuous and self.music_types[mode] is musictype:
                  return
              self.music_types[mode] = musictype
  
              # If the OS tells us there's currently music playing,
              # all our operations default to playing nothing.
              if _ba.is_os_playing_music():
                  musictype = None
  
              # If we're not in the mode this music is being set for,
              # don't actually change what's playing.
              if mode != self._music_mode:
                  return
  
              # Some platforms have a special music-player for things like iTunes
              # soundtracks, mp3s, etc. if this is the case, attempt to grab an
              # entry for this music-type, and if we have one, have the
              # music-player play it.  If not, we'll play game music ourself.
              if musictype is not None and self._music_player_type is not None:
                  if testsoundtrack is not None:
                      soundtrack = testsoundtrack
                  else:
                      soundtrack = self._get_user_soundtrack()
                  entry = soundtrack.get(musictype.value)
              else:
                  entry = None
  
              # Go through music-player.
              if entry is not None:
                  self._play_music_player_music(entry)
  
              # Handle via internal music.
              else:
                  self._play_internal_music(musictype)
code_tokens: def do_play_music ( self , musictype : Union [ MusicType , str , None ] , continuous : bool = False , mode : MusicPlayMode = MusicPlayMode . REGULAR , testsoundtrack : dict [ str , Any ] = None ) -> None : if musictype is not None : try : musictype = MusicType ( musictype ) except ValueError : print ( f"Invalid music type: '{musictype}'" ) musictype = None with _ba . Context ( 'ui' ) : if continuous and self . music_types [ mode ] is musictype : return self . music_types [ mode ] = musictype if _ba . is_os_playing_music ( ) : musictype = None if mode != self . _music_mode : return if musictype is not None and self . _music_player_type is not None : if testsoundtrack is not None : soundtrack = testsoundtrack else : soundtrack = self . _get_user_soundtrack ( ) entry = soundtrack . get ( musictype . value ) else : entry = None if entry is not None : self . _play_music_player_music ( entry ) else : self . _play_internal_music ( musictype )
short_docstring: Plays the requested music type/mode.
short_docstring_tokens: Plays the requested music type / mode .
comment: """Plays the requested music type/mode.
  
          For most cases, setmusic() is the proper call to use, which itself
          calls this. Certain cases, however, such as soundtrack testing, may
          require calling this directly.
          """$SEP$# We can be passed a MusicType or the string value corresponding$SEP$# to one.$SEP$# If they don't want to restart music and we're already$SEP$# playing what's requested, we're done.$SEP$# If the OS tells us there's currently music playing,$SEP$# all our operations default to playing nothing.$SEP$# If we're not in the mode this music is being set for,$SEP$# don't actually change what's playing.$SEP$# Some platforms have a special music-player for things like iTunes$SEP$# soundtracks, mp3s, etc. if this is the case, attempt to grab an$SEP$# entry for this music-type, and if we have one, have the$SEP$# music-player play it.  If not, we'll play game music ourself.$SEP$# Go through music-player.$SEP$# Handle via internal music.