Skip to main content

A python package to play and control media files.

Project description

playmedia

A python module to play and control media files.

Installation

pip install playmedia

Dependencies

Usage

  1. class File

    You 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 playback

    args = None, return = string

    • pause(status)

    This method pauses/resumes the playback

    args = [status: boolean], return = string

    • mute(status)

    This method mutes/unmutes the playback

    args = [status: boolean], return = string

    • set_volume(vol)

    This method set the volume of the playback

    args = [vol: int], defaults = [vol: 100], return = string

    • stop()

    This method stops the playback

    args = None, return = None

    • meta(tag)

    This method returns the meta data of the media

    args = [tag: string], defaults = [tag: "Date"], return = string

    • edit_meta(tag, new_value)

    This method changes the meta data values

    args = [tag: string, new_value: string], return = string

    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, URL

    instance = File("path/of/the/media/file/Why do I?.mp3")
    instance.start() # Returns Now playing Why do I?
    instance.pause(True) # Returns Paused
    instance.mute(False) # Returns Unmuted
    instance.set_volume(75) # Returns Volume set to 75%
    instance.meta("Artist") # Returns Artist: Unknown Brain
    instance.edit_meta("Album","playmedia") # Changed Album to playmedia
    instance.stop()
    

    Note: Statements are returned not printed. To print the returned values use print(instance.set_volume(75))

    • stop()

    args = None, return = None

  2. class Files

    You 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")
     or
     Files(["path/to/media/file/1", "path/to/media/file/2"])
    
    • get_list()

    This method returns a dictionary with index as keys and files as values

    args = None, return = dictionary

    • start()

    This method starts the playback in order

    args = None, return = dictionary

    • play_at_index(index)

    This method starts the playback of the media file at the given index

    args = [index: int], return = string

    • pause(status)

    This method pauses/resumes the playback

    args = [status: boolean], return = string

    • next()

    This method skips the current media and plays the next one

    args = None, return = string

    • previous()

    This method plays the previous media

    args = None, return = string

    • mute(status)

    This method mutes/unmutes the playback

    args = [status: boolean], return = string

    • set_volume(vol)

    This method set the volume of the playback

    args = [vol: int], defaults = [vol: 100], return = string

    • stop()

    This method stops the playback

    args = None, return = None

    • current_meta(tag)

    This method returns the meta data of the currently playing media

    args = [tag: string], defaults = [tag: "Date"], return = string

    Note: 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, URL

    • current_time()

    args = None, return = dictionary

    instance = 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 2
    instance.pause(True) # Returns Paused
    instance.mute(False) # Returns Unmuted
    instance.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 use print(instance.set_volume(75))

Supported Files

  1. '.m4a'
  2. '.flac'
  3. '.mp3'
  4. '.mp4'
  5. '.wav'
  6. '.wma'
  7. '.aac'
  8. '.mkv'

Author

Satvik Virmani

Contributions

Contributions, issues and feature requests are welcome! Feel free to check issues page.

Show your support

Give a ⭐️ if this project helped you!

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

playmedia-1.0.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

playmedia-1.0.0-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file playmedia-1.0.0.tar.gz.

File metadata

  • Download URL: playmedia-1.0.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for playmedia-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e131fa9090448eb8c53eccd3ebc6049b6239015115d57cd9be125c0030ab00a7
MD5 c148e2c4dcd8cc7a9873cd22d176f940
BLAKE2b-256 1a826874bd49adecbc5e0fbe8ab178318ea43cdadd24d755a40bca152ed94695

See more details on using hashes here.

File details

Details for the file playmedia-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: playmedia-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.4

File hashes

Hashes for playmedia-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 111b9efbae2823eb3fe370fe63a610479a3c5d9f127d31500f198151f764eb36
MD5 540f352eb088218c26eab906decac669
BLAKE2b-256 9c88df46fcd0873c9052bca8ccf470e4eaf0aebac23f57fed309b87a080c8f5a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page