A python package to play and control media files
Project description
playmedia
Install
pip install playmedia
playmedia python package helps you easily play and control media files. It uses multithreading technology ( playback run in a different thread ). It means after calling play_single( filepath )
or play_multiple( directoryPath, shuffle )
execution of program does not stop.
Example :-
from playmedia import *
play_single("C:\\Users\\Satvik\\Music\\Why do I.mp3")
print("This is printed as soon as play_single() is called. It does not wait for song to finish")
#Output :
This is printed as soon as play_single() is called. It does not wait for song to finish
It supports almost all popular formats :-
- .m4a
- .flac
- .mp3
- .mp4
- .wav
- .wma
- .aac
- .mkv
It has 2 major functions :-
- play_single()
- play_multiple()
1. play_single( filepath )
play_single( filepath )
- filepath ->full path of loaction of media eg.("C:\\Users\\Satvik\\Music\\Why do I.mp3"). Double backslash( \\ ) should be used as using others might throw unicode error.
It has 3 method inside it.
-
pause_single()
- Pauses the song. (callingpause_single()
again resumes it) -
set_volume_single(vol)
- Sets the volume of player to vol%. Eg.set_volume_single(60)
sets volume to 60% -
stop_single()
- Stops playing . Only it should be called to stop playing. Using other techniques might stop playing but not stop the thread
Example Usage :-
from playmedia import *
play_single("C:\\Users\\Satvik\\Music\\Why do I.mp3")
#playing started
pause_single()
#pauses
pause_single()
#calling pause_single() again resumes the song
set_volume_single(60)
#sets volume to 60%
stop_single()
#stops playing the song
2. play_multiple( directoryPath, shuffle )
play_multiple( directoryPath, shuffle )
- directoryPath ->full path of directory containing multiple media eg.("C:\\Users\\Satvik\\Music\"). Double backslash( \\ ) should be used as using others might throw unicode error. Also double backslash( \\ ) at the end is neccesary.
- shuffle ->True if you want the songs to be played in random order else False
It has 5 method inside it.
-
pause_multiple()
- Pauses the song. (callingpause_multiple()
again resumes it) -
set_volume_multiple(vol)
- Sets the volume of player to vol%. Eg.set_volume_multiple(60)
sets volume to 60% -
next_multiple()
- Plays next song in the list -
previous_multiple
- Plays previous song in the list -
stop_multiple()
- Stops playing . Only it should be called to stop playing. Using other techniques might stop playing but not stop the thread
Example Usage:-
from playmedia import *
play_multiple("C:\\Users\\Satvik\\Music\\", False)
#started playing
pause_multiple()
#pauses the current song
pause_multiple()
#calling pause_multiple() again resumes the current song
next_multiple()
#plays next song in the list
previous_multiple()
#plays previous song in the list
set_volume_multiple(60)
#sets volume to 60%
stop_multiple()
#stops playing the songs
🤝Contributing
Contributions, issues and feature requests are welcome! Feel free to check Bug Tracker page. To submit improvements or features check Pull Requests
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for playmedia-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a86983cbc03127c63b2acdc49d091dda2762b3fc96914431fc7f7c094285471b |
|
MD5 | 679a68f746e2fb75fb022520e5e17e6c |
|
BLAKE2b-256 | d11ccbae52d660ae4b7dfbd25ecab2f0c1c80f6def52f2cda4a283e7261f5a23 |