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.10.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.3.10-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: seaplayer_audio-0.3.10.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.3.10.tar.gz
Algorithm Hash digest
SHA256 15f0e1ca5eef8fdcf9b5acd516258eea5911cfa892c4c426d5345050a44c1e94
MD5 f75414ddff20f41f68bd4e140458cb83
BLAKE2b-256 3b811f7084f78231df588b08aa8559ffbf8813037f40ba47edf9dc0e5c9343c6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: seaplayer_audio-0.3.10-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.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 1db03c35f9b5bbd7964b9ec1551e3b9426868495c31f9181e20d31680cd535e2
MD5 a39c800da5140be36f3d4fe56650d9cb
BLAKE2b-256 7c29522f49cf131f3bbaa28f90ff7916059f20204a451273eea65e76237c03d1

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