Garry's Mod

Garry's Mod

Media Player
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?
< >
Näytetään 1-1 / 1 kommentista
Sam  [kehittäjä] 15.7.2017 klo 15.35 
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
< >
Näytetään 1-1 / 1 kommentista
Sivua kohden: 1530 50