terremoth / php-win32-playwav
Play wav (wave) files natively with PHP on Windows
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/terremoth/php-win32-playwav
Requires
- php: ^8.1
- ext-ffi: *
Requires (Dev)
- nikic/php-parser: ^4.10
- phpmd/phpmd: @stable
- phpunit/phpunit: ^10.0
- squizlabs/php_codesniffer: *
- vimeo/psalm: ^5.0
README
Play wav (wave) files natively with PHP on Windows. Zero extensions or dependencies needed!
It uses PlaySound from winmm.dll, unlocked by the power of PHP FFI
Not because we must do it, but because we can!
Made by Terremoth with ⚡ & ❤
See demos/demo.php for examples.
Installation
composer require terremoth/php-win32-playwav
Documentation
Play Sync
<?php require 'vendor/autoload.php'; use Win32Sound\PlayWav; $sound = new PlayWav('test.wav'); $sound->play();
Play Async
<?php require 'vendor/autoload.php'; use Win32Sound\PlayWav; $sound = new PlayWav('test.wav'); $sound->async()->play();
Loop the audio
Also, you can "loop" and then, stop if you want.
IMPORTANT: loop() requires ->async() at some point, in order to work due to Windows API:
<?php require 'vendor/autoload.php'; use Win32Sound\PlayWav; $sound = new PlayWav('test.wav'); $sound->async()->loop()->play(); // if the scripts ends it will "kill" the audio process, // so, to listen just put a sleep in order to test sleep(5); // if you want to stop the looping audio, just: $sound->stop();