Music Module Overview
The entirety of Music’s scripting interface is available via PyXA.
Music Tutorials
There are currently no tutorials for the Music module.
Music Examples
The examples below provide an overview of the capabilities of the Music module.
Example 1 - Playback Control
1import PyXA
2app = PyXA.Application("Music")
3
4# Play/Pause/Stop/Resume
5app.play()
6app.pause()
7app.stop()
8app.playpause()
9
10# Fast-forward/Rewind
11app.fast_forward()
12app.rewind()
13app.resume()
Example 2 - Add Current Track to a Playlist
1import PyXA
2app = PyXA.Music()
3
4# Gather info about current track
5title = app.current_track.name
6artist = app.current_track.artist
7album = app.current_track.album
8
9# Save track to library
10library = app.sources().by_name("Library")
11app.current_track.duplicate(library)
12
13# Get the saved track object
14saved_track = app.tracks().filter("name", "==", title).filter("artist", "==", artist).by_album(album)
15
16# Add track to playlist
17playlist = app.playlists().by_name("test")
18saved_track.move(playlist)
Example 3 - Make a Playlist of Tracks in a Given Genre
1import PyXA
2app = PyXA.Music()
3
4# Get a list of all soundtrack tracks
5soundtracks = app.tracks().filter("genre", "==", "Soundtrack")
6
7# Create a new playlist
8prototype = app.make("playlist", {"name": "Soundtracks"})
9new_playlist = app.playlists().push(prototype)
10
11# Add soundtracks to the new playlist
12new_playlist.add_tracks(soundtracks)
For all classes, methods, and inherited members of the Music module, see the Music Module Reference and Media Application Reference.