Client exportları
Dynamic Island
Telefonun üstündeki island'a bir müzik çalar, bir canlı etkinlik ya da bir gizlilik noktası yerleştiren client export'ları.
Bir tray, onu oluşturan resource'a aittir. Onu yalnızca o resource değiştirebilir ya da kaldırabilir; resource durduğunda tray'leri de kaldırılır. Island'ın oyuncu için nasıl davrandığı Bildirimler ve Dynamic Island sayfasında açıklanır.
#ShowMusicTray
Island'da, Kilitli Ekran'da ve Denetim Merkezi'nde bir müzik çalar gösterir.
lua---@class MusicTrayOptions
---@field id? string your own tray id, up to 40 characters; generated when left out
---@field title string up to 60 characters
---@field artist? string up to 60 characters (`subtitle` is accepted too)
---@field cover? string image link (https:// or nui://), up to 512 characters
---@field playing? boolean true while the track plays
---@field duration? number seconds, 0 to 86400; 0 hides the progress bar
---@field position? number seconds, 0 to 86400
---@field live? boolean marks a live stream
---@field volume? number 0 to 1
---@field like? boolean
---@field shuffle? boolean
---@field repeat? 'off'|'one'|'all'
---@field output? string name of the output device, up to 24 characters
---@field layout? 'compact'|'expanded'
---@field openApp? string app id opened when the tray is pressed
---@field color? string '#RRGGBB'
---@field disabled? string[] names of controls to disable
---@field handlers? table<string, function> play, pause, next, previous, seek(position), volume(value), like(value), shuffle(value), repeat(value), close
---@param opts MusicTrayOptions
---@return string|nil id
exports['fx-phone']:ShowMusicTray(opts)
lualocal tray = exports['fx-phone']:ShowMusicTray({
title = 'Night Drive', artist = 'Synthwave FM', playing = true, duration = 214,
handlers = { play = function() resume() end, pause = function() pause() end },
})
optstablo değilse ya da id başka bir resource'un tray'ine aitsenildöndürür.- Oyuncu tray'i kapattığında
closehandler'ı çalışır (yoksastop, o da yoksapause). Trayplaying = trueile güncellendiğinde geri gelir.
#UpdateMusicTray
Bir müzik tray'ini değiştirir: yeni parça, duraklatma, konum, handler'lar.
lua---@param id string
---@param patch table|string a table of fields, or one field name
---@param value? any the value when `patch` is a field name
---@return boolean ok
exports['fx-phone']:UpdateMusicTray(id, patch, value)
luaexports['fx-phone']:UpdateMusicTray(tray, { playing = false })
exports['fx-phone']:UpdateMusicTray(tray, 'position', 95)
- Tray yoksa, müzik tray'i değilse ya da başka bir resource'a aitse
falsedöndürür.
#RemoveMusicTray
Bir müzik tray'ini kaldırır. Id verilmezse resource'unun bütün müzik tray'lerini kaldırır.
Şu adla da kullanılabilir: HideMusicTray
lua---@param id? string
---@return boolean ok always true
exports['fx-phone']:RemoveMusicTray(id)
luaexports['fx-phone']:RemoveMusicTray(tray)
#ShowLiveTray
Island'da bir canlı etkinlik gösterir: bir teslimat, bir zamanlayıcı, devam eden bir iş.
lua---@class LiveTrayButton
---@field id? string up to 20 characters
---@field label? string up to 24 characters (`title` is accepted too)
---@field icon? string icon name
---@field primary? boolean
---@field disabled? boolean
---@field onPress? function called when pressed (`cb` is accepted too)
---@class LiveTrayOptions
---@field id? string your own tray id, up to 40 characters
---@field title string up to 60 characters
---@field subtitle? string up to 60 characters
---@field icon? string icon name
---@field color? string '#RRGGBB'
---@field progress? number 0 to 1
---@field value? string short value text, up to 12 characters
---@field endsAt? number end time for a countdown
---@field waveform? boolean
---@field cover? string image link (https:// or nui://)
---@field layout? 'compact'|'expanded'
---@field openApp? string app id opened when the tray is pressed
---@field buttons? LiveTrayButton[] up to 4
---@field expanded? { lines?: string[], buttons?: LiveTrayButton[] } up to 4 lines of 60 characters and 4 buttons
---@param opts LiveTrayOptions
---@return string|nil id
exports['fx-phone']:ShowLiveTray(opts)
lualocal id = exports['fx-phone']:ShowLiveTray({
title = 'Delivery', subtitle = '2.4 km to drop-off', icon = 'truck', color = '#30D158', progress = 0.35,
})
#UpdateLiveTray
Bir canlı tray'i değiştirir.
lua---@param id string
---@param patch table|string a table of fields, or one field name
---@param value? any the value when `patch` is a field name
---@return boolean ok
exports['fx-phone']:UpdateLiveTray(id, patch, value)
luaexports['fx-phone']:UpdateLiveTray(id, 'progress', 0.8)
#RemoveLiveTray
Bir canlı tray'i kaldırır. Id verilmezse resource'unun bütün canlı tray'lerini kaldırır.
lua---@param id? string
---@return boolean ok always true
exports['fx-phone']:RemoveLiveTray(id)
luaexports['fx-phone']:RemoveLiveTray(id)
#SetIslandIndicator
Island'daki küçük bir gizlilik noktasını açar ya da kapatır.
lua---@param kind 'mic'|'camera'|'location'|'custom'
---@param on boolean
---@return boolean ok false for an unknown kind
exports['fx-phone']:SetIslandIndicator(kind, on)
luaexports['fx-phone']:SetIslandIndicator('mic', true)