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.4.0.tar.gz (12.2 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.4.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seaplayer_audio-0.4.0.tar.gz
  • Upload date:
  • Size: 12.2 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.4.0.tar.gz
Algorithm Hash digest
SHA256 ee9f8b55161fb1c94cb0daf0dbbd5fbcdb83284e2bb936c2852c141c68aa85e4
MD5 58185d853bb7232fa5240b03c40f2345
BLAKE2b-256 c5a324538adadd2c437a8cb5d3c3c1736d9fab59748f8a7d17765c7be3281e4d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seaplayer_audio-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 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.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4ea97521a07370e90587dc12e1419c46852506c82ce3e653fe5d29e0cb68c628
MD5 f0eec5bc19de873dedaceed2e316ebe6
BLAKE2b-256 0fb1fa32c3d14953f4dedae2508c7f6595f649f2461f83c20b36f950282e993a

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