Use functions to save app and device data to global
This commit is contained in:
parent
8939ecc9c5
commit
ece472b91c
|
@ -24,41 +24,8 @@ sub Main (args as dynamic) as void
|
||||||
m.global.addFields({ queueManager: CreateObject("roSGNode", "QueueManager") })
|
m.global.addFields({ queueManager: CreateObject("roSGNode", "QueueManager") })
|
||||||
m.global.addFields({ audioPlayer: CreateObject("roSGNode", "AudioPlayer") })
|
m.global.addFields({ audioPlayer: CreateObject("roSGNode", "AudioPlayer") })
|
||||||
|
|
||||||
appInfo = CreateObject("roAppInfo")
|
SaveAppToGlobal()
|
||||||
m.global.addFields({
|
SaveDeviceToGlobal()
|
||||||
app: {
|
|
||||||
id: appInfo.GetID(),
|
|
||||||
isDev: appInfo.IsDev(),
|
|
||||||
version: appInfo.GetVersion()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
' delete object
|
|
||||||
appInfo = invalid 'bs:disable-line
|
|
||||||
|
|
||||||
deviceInfo = CreateObject("roDeviceInfo")
|
|
||||||
' remove special characters
|
|
||||||
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
|
|
||||||
filteredFriendly = regex.ReplaceAll(deviceInfo.getFriendlyName(), "")
|
|
||||||
m.global.addFields({
|
|
||||||
device: {
|
|
||||||
id: deviceInfo.getChannelClientID(),
|
|
||||||
uuid: deviceInfo.GetRandomUUID(),
|
|
||||||
name: deviceInfo.getModelDisplayName(),
|
|
||||||
friendlyName: filteredFriendly,
|
|
||||||
model: deviceInfo.GetModel(),
|
|
||||||
modelType: deviceInfo.GetModelType(),
|
|
||||||
osVersion: deviceInfo.GetOSVersion(),
|
|
||||||
locale: deviceInfo.GetCurrentLocale(),
|
|
||||||
clockFormat: deviceInfo.GetClockFormat(),
|
|
||||||
isAudioGuideEnabled: deviceInfo.IsAudioGuideEnabled(),
|
|
||||||
hasVoiceRemote: deviceInfo.HasFeature("voice_remote"),
|
|
||||||
|
|
||||||
displayType: deviceInfo.GetDisplayType(),
|
|
||||||
displayMode: deviceInfo.GetDisplayMode()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
' delete object
|
|
||||||
deviceInfo = invalid 'bs:disable-line
|
|
||||||
|
|
||||||
app_start:
|
app_start:
|
||||||
' First thing to do is validate the ability to use the API
|
' First thing to do is validate the ability to use the API
|
||||||
|
|
37
source/utils/globals.brs
Normal file
37
source/utils/globals.brs
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
' Save information from roAppInfo to m.global.app
|
||||||
|
sub SaveAppToGlobal()
|
||||||
|
appInfo = CreateObject("roAppInfo")
|
||||||
|
m.global.addFields({
|
||||||
|
app: {
|
||||||
|
id: appInfo.GetID(),
|
||||||
|
isDev: appInfo.IsDev(),
|
||||||
|
version: appInfo.GetVersion()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end sub
|
||||||
|
|
||||||
|
' Save information from roDeviceInfo to m.global.device
|
||||||
|
sub SaveDeviceToGlobal()
|
||||||
|
deviceInfo = CreateObject("roDeviceInfo")
|
||||||
|
' remove special characters
|
||||||
|
regex = CreateObject("roRegex", "[^a-zA-Z0-9\ \-\_]", "")
|
||||||
|
filteredFriendly = regex.ReplaceAll(deviceInfo.getFriendlyName(), "")
|
||||||
|
m.global.addFields({
|
||||||
|
device: {
|
||||||
|
id: deviceInfo.getChannelClientID(),
|
||||||
|
uuid: deviceInfo.GetRandomUUID(),
|
||||||
|
name: deviceInfo.getModelDisplayName(),
|
||||||
|
friendlyName: filteredFriendly,
|
||||||
|
model: deviceInfo.GetModel(),
|
||||||
|
modelType: deviceInfo.GetModelType(),
|
||||||
|
osVersion: deviceInfo.GetOSVersion(),
|
||||||
|
locale: deviceInfo.GetCurrentLocale(),
|
||||||
|
clockFormat: deviceInfo.GetClockFormat(),
|
||||||
|
isAudioGuideEnabled: deviceInfo.IsAudioGuideEnabled(),
|
||||||
|
hasVoiceRemote: deviceInfo.HasFeature("voice_remote"),
|
||||||
|
|
||||||
|
displayType: deviceInfo.GetDisplayType(),
|
||||||
|
displayMode: deviceInfo.GetDisplayMode()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
end sub
|
Loading…
Reference in New Issue
Block a user