Package: playmedia
playmediaA python module to play and control media files.InstallationpipinstallplaymediaDependenciesVLC Media PlayerUsageclass FileYou can initiate the File class with the path of the media file as argument.File("path/to/the/media/file")start()This method starts the playbackargs = None, return = stringpause(status)This method pauses/resumes the playbackargs = [status: boolean], return = stringmute(status)This method mutes/unmutes the playbackargs = [status: boolean], return = stringset_volume(vol)This method set the volume of the playbackargs = [vol: int], defaults = [vol: 100], return = stringstop()This method stops the playbackargs = None, return = Nonemeta(tag)This method returns the meta data of the mediaargs = [tag: string], defaults = [tag: "Date"], return = stringedit_meta(tag, new_value)This method changes the meta data valuesargs = [tag: string, new_value: string], return = stringSupported tags = Actors, Album, AlbumArtist, Artist, ArtworkURL, Copyright, Date, Description, Director, DiscNumber, DiscTotal, EncodedBy, Episode, Genre, Language, NowPlaying, Publisher, Rating, Season, Setting, ShowName, Title, TrackID, TrackNumber, TrackTotal, URLinstance=File("path/of/the/media/file/Why do I?.mp3")instance.start()# Returns Now playing Why do I?instance.pause(True)# Returns Pausedinstance.mute(False)# Returns Unmutedinstance.set_volume(75)# Returns Volume set to 75%instance.meta("Artist")# Returns Artist: Unknown Braininstance.edit_meta("Album","playmedia")# Changed Album to playmediainstance.stop()Note: Statements are returned not printed. To print the returned values useprint(instance.set_volume(75))stop()args = None, return = Noneclass FilesYou can initiate the File class with either the path of the dirctory containing files or list with paths of the media files.Files("path/to/the/dirctory/containing/media/file")orFiles(["path/to/media/file/1","path/to/media/file/2"])get_list()This method returns a dictionary with index as keys and files as valuesargs = None, return = dictionarystart()This method starts the playback in orderargs = None, return = dictionaryplay_at_index(index)This method starts the playback of the media file at the given indexargs = [index: int], return = stringpause(status)This method pauses/resumes the playbackargs = [status: boolean], return = stringnext()This method skips the current media and plays the next oneargs = None, return = stringprevious()This method plays the previous mediaargs = None, return = stringmute(status)This method mutes/unmutes the playbackargs = [status: boolean], return = stringset_volume(vol)This method set the volume of the playbackargs = [vol: int], defaults = [vol: 100], return = stringstop()This method stops the playbackargs = None, return = Nonecurrent_meta(tag)This method returns the meta data of the currently playing mediaargs = [tag: string], defaults = [tag: "Date"], return = stringNote: A media should be playing when this method is called. Either call start(), play_at_index(index) before otherwise it raises a IndexError.Supported tags = Actors, Album, AlbumArtist, Artist, ArtworkURL, Copyright, Date, Description, Director, DiscNumber, DiscTotal, EncodedBy, Episode, Genre, Language, NowPlaying, Publisher, Rating, Season, Setting, ShowName, Title, TrackID, TrackNumber, TrackTotal, URLcurrent_time()args = None, return = dictionaryinstance=File("path/to/the/dirctory/containing/media/file")instance.get_list()# Returns {0: 'File 1.mp3', 1: 'File 2 .mp4', 2: 'File 3.wav'}instance.start()# Returns {0: 'File 1.mp3', 1: 'File 2 .mp4', 2: 'File 3.wav'}instance.stop()instance.play_at_index(1)# Returns Now playing File 2instance.pause(True)# Returns Pausedinstance.mute(False)# Returns Unmutedinstance.set_volume(75)# Returns Volume set to 75%instance.current_meta("Artist")# Returns Artist: "Artist of File 2"instance.current_time("Album","playmedia")# Returns {"Current time": '98.63s'}Note: Statements are returned not printed. To print the returned values useprint(instance.set_volume(75))Supported Files'.m4a''.flac''.mp3''.mp4''.wav''.wma''.aac''.mkv'AuthorSatvik VirmaniContributionsContributions, issues and feature requests are welcome!
Feel free to checkissuespage.Show your supportGive a ⭐️ if this project helped you!