Garry's Mod

Garry's Mod

Media Player
Simone 27 Jun, 2017 @ 4:18pm
How can I manage all existing media players?
I'm writing a modified version of this addon, where users can create radio stations that others can browse and play through an interface. How can I get a list of existing media players and their current status?
< >
Showing 1-1 of 1 comments
Sam  [developer] 15 Jul, 2017 @ 3:35pm 
MediaPlayer.GetAll() will return a list of all active media players
https://github.com/pixeltailgames/gm-mediaplayer/blob/master/lua/mediaplayer/sh_mediaplayer.lua#L195

This will return a MEDIAPLAYER object
https://github.com/pixeltailgames/gm-mediaplayer/tree/master/lua/mediaplayer/players/base

Here's some sample code
-- Get all media players local mps = MediaPlayer.GetAll() for _, mp in pairs(mps) do -- Get the active media local media = mp:GetMedia() if media then -- Get media's metadata -- See mediaplayer/services/base/shared.lua for more local title = media:Title() local duration = media:Duration() end end
< >
Showing 1-1 of 1 comments
Per page: 1530 50