Garry's Mod

Garry's Mod

Media Player
Simone 2017 年 6 月 27 日 下午 4:18
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?
< >
正在显示第 1 - 1 条,共 1 条留言
Sam  [开发者] 2017 年 7 月 15 日 下午 3: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
< >
正在显示第 1 - 1 条,共 1 条留言
每页显示数: 1530 50