Skip to main content

A library for async/sync playback audio.

Project description

seaplayer-audio

Description

The SeaPlayer library for async/sync playback audio.

The module is still under DEVELOPMENT, so I do not recommend using it in your projects.

Supported formats

It is based on the sounddevice and soundfile module.

soundfile, in turn, is a wrapper of the C library libsndfile, which has limitations in file reading formats. More info...

Usage (synchronously)

Through context manager

import time
from seaplayer_audio import CallbackSoundDeviceStreamer, FileAudioSource


def main():
    with FileAudioSource('example.mp3') as source:
        with CallbackSoundDeviceStreamer() as streamer:
            while len(data := source.readline(1)) > 0:
                streamer.send( data )
                time.sleep(0.01) # Optional


if __name__ == '__main__':
    main()

Through cycle

import time
from seaplayer_audio import CallbackSoundDeviceStreamer, FileAudioSource


def main():
    file = FileAudioSource('example.mp3')
    streamer = CallbackSoundDeviceStreamer()
    streamer.start()
    while len(data := source.readline(1)) > 0:
        streamer.send( data )
        time.sleep(0.01) # Optional
    streamer.stop()
    file.close()


if __name__ == '__main__':
    main()

Usage (asynchronously)

Through context manager

import asyncio
from seaplayer_audio import AsyncCallbackSoundDeviceStreamer, AsyncFileAudioSource


async def main():
    async with AsyncFileAudioSource('example.mp3') as source:
        async with AsyncCallbackSoundDeviceStreamer() as streamer:
            while len(data := await source.readline(1)) > 0:
                await streamer.send( data )
                await asyncio.sleep(0.01) # Optional


if __name__ == '__main__':
    asyncio.run(main())

Through cycle

import asyncio
from seaplayer_audio import AsyncCallbackSoundDeviceStreamer, AsyncFileAudioSource


async def main():
    file = FileAudioSource('example.mp3')
    streamer = CallbackSoundDeviceStreamer()
    await streamer.start()
    while len(data := await source.readline(1)) > 0:
        await streamer.send( data )
        await asyncio.sleep(0.01) # Optional
    await streamer.stop()
    await file.close()


if __name__ == '__main__':
    asyncio.run(main())

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

seaplayer_audio-0.3.3.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

seaplayer_audio-0.3.3-py3-none-any.whl (17.9 kB view details)

Uploaded Python 3

File details

Details for the file seaplayer_audio-0.3.3.tar.gz.

File metadata

  • Download URL: seaplayer_audio-0.3.3.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Windows/10

File hashes

Hashes for seaplayer_audio-0.3.3.tar.gz
Algorithm Hash digest
SHA256 cc45e2437b04a44f128fab96976e0c5946fa012cea90f6e8c05d8b9622db765d
MD5 03d356a9f9eefb264103a04da2c0ffe7
BLAKE2b-256 8d912ffe0651d78cb3428f3e352f029ad53ea9039f126a589b2fdbb9bbf183f5

See more details on using hashes here.

File details

Details for the file seaplayer_audio-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: seaplayer_audio-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 17.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.4 CPython/3.12.7 Windows/10

File hashes

Hashes for seaplayer_audio-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 927cfa1f09d228e3aa8c3b14dbfc7b5e57a7c1dc20aeba124db4a8321ac6ea64
MD5 eba7a1889da999537b36a9c3feb47044
BLAKE2b-256 cc4df4eb2229edbd45d90caeb37ecbeaaabfd335fdb4644c949ff4950def4542

See more details on using hashes here.

Supported by

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