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.2.0.tar.gz (10.1 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.2.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seaplayer_audio-0.2.0.tar.gz
  • Upload date:
  • Size: 10.1 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.2.0.tar.gz
Algorithm Hash digest
SHA256 d1e23231b394d0125476adbc1ee37b59c4fb2516edb832bfb85e886131ae3ea4
MD5 386548e129b8f15e201b56d91f1d70cd
BLAKE2b-256 0f31087e5e9f04941149e3c3854a5e5453113ed38e9bf780004cbb59b6f7dd72

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seaplayer_audio-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a94897f34450f9520e5ed3e75b83174a23298af551abd9b9bdfc2d7589ef2ffd
MD5 645010f4d9c30e235d5b9e32d3ec973f
BLAKE2b-256 6734577b2f030d7830b42f89ae0a5ffa3f0952cee626c84990b9e9d0fdd52f64

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