Getting started
Installation
Before using pYTerm, it is highly recommended you install vlc media player while this isn’t required, and pYTerm will mostly work using the alternative FFPyPlayer backend, this is currently quite unstable and can lead to unexpected errors and crashes.
You can install pYTerm through pip with the following command:
python -m pip install p-yt-erm
And then import it like this:
1from pYTerm import pYTerm
Usage
The most straight-forward way of using pYTerm is by just calling .play() like this:
1from pYTerm import pYTerm
2
3myplayer = pYTerm.Player()
4myplayer.play("Girl in red - body and mind")
which will just play the song without any hassle. This is just scratching the surface of pYTerm though! Here’s a slightly more involved example:
1from pYTerm import pYTerm
2
3myplayer = pYTerm.Player( volume=50, playlists = 'the first glass beach album' )
4
5myplayer.shuffle()
6
7myplayer.play_all( halting = True, keep_alive = False )
8# will wait until the playlist is finished playing
9
10myplayer.add_song('girl in red - body and mind')
11
12myplayer.play_all( halting = False, keep_alive = True )
13# will not wait
14
15myplayer.add_song('https://www.youtube.com/watch?v=20SbrlLmOJA')
16
17myplayer.add_playlist('life is strange original soundtrack')
All player controls such as skipping, timeline scrubbing, etc. are also accessible through various class functions:
1from pYTerm import pYTerm
2
3myplayer = pYTerm.Player( volume=50, playlists = 'the first glass beach album' )
4myplayer.play_all( halting = False, keep_alive = True )
5
6myplayer.wait_on_song_load()
7
8myplayer.next()
9myplayer.wait_on_song_load()
10
11myplayer.pause()
12myplayer.toggle_mute()
13myplayer.unmute()
14myplayer.unpause()
15myplayer.scrub(10) # fast forward 10 seconds
16myplayer.scrub(-5) # fast backwards 5 seconds
17
18myplayer.next()
19myplayer.wait_on_song_load()
20
21while myplayer.is_alive():
22 print('song is at', myplayer.get_current_time(), 'out of', myplayer.get_total_time())
To see a list of everything you can toy around with, take a look at main player class documentation.