samp.directory
← Scripts et bibliothèques

Walter-Correa/SampAudioStream

A high-performance, asynchronous C++20 universal audio streaming plugin and native component engineered specifically for SA-MP and Open.MP.

Plugin★ 1mis à jour il y a 3 joursMPL-2.0C++sampctl
Ouvrir sur GitHub

Installer avec sampctl

sampctl package install Walter-Correa/SampAudioStream

Lance ceci dans le dossier de ton projet. sampctl télécharge le paquet et ce dont il dépend.

L’essayer dans le compilateur Pawn →

Ajoute ses fichiers include, avec les bibliothèques dont il dépend, au compilateur Pawn de ton navigateur, prêts à être inclus dans un script.

Dépend de 1 paquet

README.md

SampAudioStream

SampAudioStream is a high-performance, asynchronous C++20 universal audio streaming plugin and native component engineered specifically for San Andreas Multiplayer (SA-MP) and open.mp.

It allows Pawn developers to play audio from YouTube, SoundCloud, Twitch, Kick, Vimeo, TikTok, and hundreds of other video/audio platforms—as well as live broadcasts, Shoutcast/Icecast online radios, HLS streams, and direct MP3/OGG/WAV/FLAC links—with no installation on Windows and a single package on Linux (32-bit libcurl), zero ffmpeg dependency, built-in in-memory MP3 transcoding, spatial 3D/world/interior filtering, time-synchronized radius playback, asynchronous in-game music search, and synchronized multi-player radio channels.


Extending Standard SA-MP / open.mp AudioStream

Feature / CapabilityStandard PlayAudioStreamForPlayerSampAudioStream
Platform ArchitectureBuilt-in server native✅ Unified dual-runtime binary: native open.mp Component + SA-MP Plugin (32-bit x86)
Server DependenciesNone✅ Windows: none · Linux: 32-bit libcurl only (the server log prints the exact install command); static CRT (/MT & -static-libstdc++), embedded codecs, auto-provisioned yt-dlp + quickjs-ng
Transcoding EngineClient plays direct HTTP audio only✅ Embedded static C++ pipeline (libopus, libogg, fdk-aac, mp3lame, dr_libs, stb_vorbis) + ICY StreamTitle framing
Video, Audio & Live SitesDirect .mp3/.ogg/Shoutcast only✅ YouTube (videos & lives incl. RFC 8216 ADTS/fMP4), SoundCloud, Twitch, Kick, Vimeo, TikTok, HLS (.m3u8 / MPEG-TS), extensionless Shoutcast/Icecast & more
Drop-In CompatibilityNative behavior✅ Transparently hooks PlayAudioStreamForPlayer & StopAudioStreamForPlayer, LAN-aware local URLs, CP1252 Pawn encoding default + full SA_* API
World / Interior / VolumeGlobal usepos only; no server volume scaling✅ Native worldid, interiorid, and volume (0.0–200.0) parameters
Radius Time SynchronizationStatic URL starts from beginning per player✅ SA_PlayAudioStream paces finite tracks at 1x real-time so latecomers entering the radius hear the current timestamp
In-Game Music Search❌ None✅ Non-blocking SA_SearchAudioStream returning structured results via callbacks for interactive Pawn dialogs
Dynamic 3D AttachmentStatic coordinates only✅ SA_AttachAudioStreamToPlayer & SA_AttachAudioStreamToVehicle
Synchronized Radio Channels❌ None✅ SA_CreateAudioStreamChannel, SA_QueueChannelAudioStream, SA_SkipChannelAudioStream, 3D positional/vehicle/player channels, queue manipulation & loop modes, elapsed/listener queries, creator ownership, passwords, destroy policies, and atomic JSON disk persistence
Caching & Memory FootprintUncached client HTTP requests✅ In-memory LRU+TTL metadata/search cache + ~30s sliding ring buffers (zero MP3 disk bloat)

Documentation Hub

Modular guides and exhaustive API documentation are available in the docs/ directory:

GuideDescription
📖 Getting StartedRequirements, installation for SA-MP & open.mp, firewall setup, first startup log, config.json reference, troubleshooting, and FAQ.
🔊 Playback, Hooking & Spatial AudioSA_PlayAudioStreamForPlayer vs. SA_PlayAudioStream, radius time sync, live streams, volume, pause, and 3D entity attachment.
🔎 Music Search & Synced ChannelsAsynchronous SA_SearchAudioStream dialog workflows and synchronized multi-player radio stations with passwords, creator lifecycle, and queues.
⚙️ Architecture, Transcoding & CachingInternal C++20 worker pool, embedded codecs, HLS/MPEG-TS live decoding, LRU RAM cache, and ~30s ring buffers.
📚 Complete API ReferenceExhaustive reference for all 91 SA_* natives, hooked vanilla natives, 20 callbacks, enums, constants, and helpers (plus optional audio.normalize_volume equalization for transcoded/proxy streams and live broadcasts, excluding direct passthrough).
⚠️ Important NotesExtractor (yt-dlp) dependency notice, server owner content responsibility, and non-affiliation disclaimer.

Important Notes

  • Platform Extractor Dependency (yt-dlp): Platform streams (YouTube, SoundCloud, Twitch, etc.) are resolved by yt-dlp, which the plugin downloads and keeps updated automatically. When a platform changes its internals, extraction may fail temporarily until a new yt-dlp release is published and picked up by the automatic update. Direct audio URLs and internet radios do not depend on yt-dlp. See Troubleshooting for how to force an update and the YouTube Cookies Guide if YouTube challenges your VPS IP with "Sign in to confirm you're not a bot".
  • Content Responsibility: SampAudioStream does not host, store, or distribute any media. It only relays audio that the server owner (or players, through your scripts) chooses to play. Server owners are solely responsible for ensuring they have the rights to broadcast the content played on their servers and for complying with the terms of service of the platforms they stream from.
  • No Affiliation: SampAudioStream is an independent community project and is not affiliated with, endorsed by, or sponsored by YouTube, Google, SoundCloud, Twitch, Take-Two Interactive, Rockstar Games, the SA-MP team, or the open.mp team. All trademarks belong to their respective owners.

Quick Start & Installation

Follow these 5 steps to install SampAudioStream and play your first track:

  1. Download the release archive for your server OS: download SampAudioStream-Windows.zip or SampAudioStream-Linux.zip from GitHub Releases (matching the server host OS). Verify the archive contains plugins/, components/, include/SampAudioStream.inc, and filterscripts/FS_SampAudioStream_Demo.{pwn,amx}. (Full details)

  2. Check host dependencies: Windows requires nothing extra; Linux requires 32-bit libcurl (libcurl.so.4). If libcurl is missing on Linux, the server log prints the exact install command for your distribution. (Distribution commands)

  3. Copy the binary folder and include file: copy only one binary folder (plugins/ or components/ — never both) plus include/SampAudioStream.inc into pawno/include/ (SA-MP) or qawno/include/ (open.mp). (Installation guide)

    Server RuntimeBinary FolderConfig Edit Required?
    SA-MP 0.3.7plugins/Yes, add plugins SampAudioStream.dll (or .so) in server.cfg
    open.mp (recommended)components/No (loaded automatically)
    open.mp legacy modeplugins/Yes, add "SampAudioStream" under pawn.legacy_plugins in config.json

    [!IMPORTANT] Copy only one binary folder (plugins/ or components/). Loading both in the same server process is rejected.

  4. Open the streaming TCP port: allow inbound TCP traffic on every port of network.http_port (default 7778-7785, the first free one is used) in your OS firewall and VPS security group (note: LAN players automatically receive local/loopback URLs when lan_aware_urls is true, while remote players require port-forwarding). Start the server and confirm HTTP audio streaming server listening on ... appears in the console log. (Firewall & verification steps)

  5. Include <SampAudioStream> in your Pawn script and compile: place #include <SampAudioStream> after <open.mp> or <a_samp>, then recompile and start playing audio. Confirm yt-dlp ... downloaded and SHA-256 verified and QuickJS-ng downloaded and SHA-256 verified appear on first boot. (First startup log)

#include <open.mp> // Or <a_samp>
#include <SampAudioStream>

CMD:play(playerid, params[])
{
    if (isnull(params)) return SendClientMessage(playerid, -1, "Usage: /play <URL or song name>");

    // Works with YouTube, SoundCloud, Twitch, direct MP3, radios, or plain search text
    SA_PlayAudioStreamForPlayer(playerid, params, 0.0, 0.0, 0.0, 50.0, false, -1, -1, 90.0);
    return 1;
}

CMD:zone(playerid, params[])
{
    if (isnull(params)) return SendClientMessage(playerid, -1, "Usage: /zone <URL or song name>");

    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);

    // Everyone entering the 35m radius hears the song synchronized at its current timestamp
    SA_PlayAudioStream(params, x, y, z, 35.0, true, GetPlayerVirtualWorld(playerid), GetPlayerInterior(playerid), 85.0);
    return 1;
}

See FS_SampAudioStream_Demo.pwn for a complete plug-and-play English showcase filterscript (/audiomenu / /sa) demonstrating all 91 SA_* natives, hooked vanilla functions, player mute/source tracking, global pause, stream listing/stats, playlist import, seeking, queue item moving, listener skip voting, previous-track history, live radio text inspection/overrides, boombox/vehicle attachment, volume/position/distance controls, local music library browsing, channel playlist mode, sound effects, on-screen stream text toggle, persistent or temporary channels, and synchronized radio channels.


Complete API Reference

All 91 SA_* natives, hooked vanilla functions, 20 callbacks, constants, and enums are documented with signatures and examples in docs/api-reference.md:

  • Playback & Control: SA_PlayAudioStreamForPlayer, SA_PlayAudioStream, SA_StopAudioStreamForPlayer, SA_StopAudioStream, SA_PauseAudioStreamForPlayer, SA_PauseAudioStream, SA_SeekAudioStream, SA_SetPlayerAudioStreamMuted, SA_IsPlayerAudioStreamMuted, SA_SetPlayerAudioStreamGroupMuted, SA_IsPlayerAudioStreamGroupMuted, SA_GetPlayerAudioStreamSource, SA_SetPlayerAudioStreamVolume, SA_SetAudioStreamVolume, SA_SetPlayerAudioStreamDistance, SA_SetAudioStreamDistance, SA_SetPlayerAudioStreamPos, SA_SetAudioStreamPos
  • Spatial & Entity Attachment: SA_AttachAudioStreamToPlayer, SA_AttachAudioStreamToVehicle
  • Asynchronous Music Search: SA_SearchAudioStream, SA_CancelAudioStreamSearch
  • Synchronized Radio Channels: SA_CreateAudioStreamChannel, SA_DestroyAudioStreamChannel, SA_SetAudioStreamChannelName, SA_GetAudioStreamChannelLiveTitle, SA_SetAudioStreamChannelLiveTitle, SA_PlayChannelAudioStream, SA_QueueChannelAudioStream, SA_QueueChannelAudioStreamPlaylist, SA_SeekChannelAudioStream, SA_RemoveAudioStreamChannelQueue, SA_InsertAudioStreamChannelQueue, SA_ReplaceAudioStreamChannelQueue, SA_MoveAudioStreamChannelQueue, SA_ShuffleAudioStreamChannelQueue, SA_SkipChannelAudioStream, SA_StopChannelAudioStream, SA_PauseChannelAudioStream, SA_SetChannelAudioStreamVolume, SA_SetAudioStreamChannelLoop, SA_GetAudioStreamChannelLoop, SA_SetAudioStreamChannelPos, SA_ClearAudioStreamChannelPos, SA_SetAudioStreamChannelGroup, SA_GetAudioStreamChannelGroup, SA_AttachAudioStreamChannelToPlayer, SA_AttachAudioStreamChannelToVehicle, SA_JoinAudioStreamChannel, SA_LeaveAudioStreamChannel, SA_IsPlayerInAudioStreamChannel, SA_GetPlayerAudioStreamChannel, SA_SetAudioStreamChannelPass, SA_CheckAudioStreamChannelPass, SA_SetAudioStreamChannelCreator, SA_SetAudioStreamChannelDestroy, SA_GetAudioStreamChannelDestroy, SA_SetAudioStreamChannelIdleSuspend, SA_GetAudioStreamChannelIdleSuspend, SA_GetAudioStreamChannelCount, SA_GetAudioStreamChannelID, SA_GetAudioStreamChannelInfo, SA_GetAudioStreamChannelTrack, SA_GetAudioStreamChannelElapsed, SA_GetAudioStreamChannelListener, SA_GetAudioStreamChannelQueue, SA_GetAudioStreamChannelQueueLabel, SA_SetAudioStreamChannelQueueLabel, SA_SetAudioStreamChannelDescription, SA_GetAudioStreamChannelDescription, SA_SetAudioStreamChannelQueueDescription, SA_GetAudioStreamChannelQueueDescription, SA_GetAudioStreamChannelTrackDescription, SA_FindAudioStreamChannelQueue, SA_ClearAudioStreamChannelQueue
  • Diagnostics & Metadata: SA_GetPlayerAudioStreamID, SA_GetAudioStreamCount, SA_GetAudioStreamID, SA_GetAudioStreamOwner, SA_GetAudioStreamElapsed, SA_GetAudioStreamURL, SA_GetAudioStreamStats, SA_GetAudioStreamInfo, SA_GetAudioStreamLiveTitle, SA_SetAudioStreamLiveTitle, SA_IsAudioStreamExtractorReady, SA_GetAudioStreamHttpPort
  • Hooked Vanilla Natives: PlayAudioStreamForPlayer, StopAudioStreamForPlayer
  • Callbacks: OnAudioStreamProcessing, OnAudioStreamWaiting, OnAudioStreamReady, OnAudioStreamStart, OnAudioStreamFinished, OnAudioStreamError, OnAudioStreamLiveTitleChange, OnPlayerAudioStreamSourceChange, OnPlayerAudioStreamNoConnect, OnAudioStreamSearchResults, OnAudioStreamSearchResultItem, OnAudioStreamChannelDestroyed, OnAudioStreamChannelTrackWaiting, OnAudioStreamChannelTrackStart, OnAudioStreamChannelQueueEnd, OnAudioStreamChannelError, OnAudioStreamChannelRestored, OnAudioStreamChannelPlaylistQueued, OnAudioStreamChannelLiveTitleChange

Building from Source

Prerequisites

  • CMake 3.20+ and Git (dependencies nlohmann_json, asio, ogg, opus, fdk-aac, mp3lame_static, dr_libs, and stb are fetched automatically via CMake FetchContent)
  • Windows: Visual Studio 2022 (Desktop C++ workload)
  • Linux: GCC 10+ / Clang with gcc-multilib g++-multilib (for -m32 x86 builds)
  • SDKs in deps/:
    git clone --depth 1 --recurse-submodules --shallow-submodules https://github.com/openmultiplayer/open.mp-sdk.git deps/open.mp-sdk
    git clone --depth 1 https://github.com/maddinat0r/samp-plugin-sdk.git deps/samp-plugin-sdk
    
    The commits used by official builds are pinned in cmake/sdk-pins.txt.

Compiling on Windows (1-Click Script)

Run the automated MSVC build script:

build_msvc.bat

(Automatically configures CMake for Win32, compiles Release binaries, runs core_tests, and builds dist/SampAudioStream-Windows.zip.)

Compiling on Linux

cmake -B build -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=cmake/linux-x86.cmake
cmake --build build --parallel
ctest --test-dir build -R core_tests --output-on-failure

Version history

Show the version history

Unreleased

  • Updated Libraries:
    • nlohmann/json 3.12.0, asio 1.39.0, libogg 1.3.6, libopus 1.6.1, fdk-aac 3.0.0, stb_vorbis 1.25 (stricter checks on malformed Ogg files) and the latest dr_libs (dr_flac, dr_wav and dr_mp3 fixes for malformed files).
  • Fixes:
    • open.mp reported the component as version 2.2.0; it now reports the real version.
  • Maintenance Automation (repository only):
    • A weekly workflow opens pull requests for new Deno / QuickJS-ng releases (with recomputed download hashes) and new open.mp / SA-MP SDK commits, and keeps an issue listing newer library releases; each says whether a new release is needed. See docs/maintenance.md.
    • Changes waiting for a release are listed under "Unreleased" in this version history. The Release workflow asks for the version type (patch, minor or major), sets the version in every file, turns "Unreleased" into the new version and publishes it.

Lire la suite sur GitHub

3d-audioaudioaudio-streamingmusicopen-mpopenmppawnradiosa-mpsampsamp-pluginsoundstreaming

Cette page est construite à partir de ce que GitHub publie sur le dépôt. samp.directory n’héberge pas le code. Signaler un problème avec cette fiche

Walter-Correa/SampAudioStream : Plugin SA-MP | samp.directory