I tried it in new project it showed the following error.Any help will be much appreciated.
Thank you.
BRIGHTSCRIPT: ERROR: ParseJSON: Data is empty: pkg:/source/Utils.brs(18)
Utils.brs:
Sub playDefaultClip(app)
sizeRect = app.canvas.GetCanvasRect()
app.player.SetDestinationRect(sizeRect) 'fullscreen
contentList = []
contentList.Push({
Stream: { url: "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8" }
StreamFormat: "hls"
})
app.player.SetContentList(contentList)
app.player.play()
print "playing!"
End Sub
Function LoadNavigationContent(contentURL)
jsonAsString = ReadAsciiFile(contentURL)
[color=#FF0000]content = ParseJSON(jsonAsString)[/color]
return content
End Function
app controller:
' Factory method
Function initApp()
player = CreateObject("roVideoPlayer")
canvas = createObject("roImageCanvas")
port = CreateObject("roMessagePort")
canvas.SetMessagePort(port)
canvas.SetRequireAllImagesToDraw(false)
player.SetMessagePort(port)
player.SetLoop(false)
'player.SetPositionNotificationPeriod(5)
navigationContentURL = "pkg:/json/content.json"
navContent = LoadNavigationContent(navigationContentURL)
controls = {
menuControl:initMenuControl(navContent)
playerControl:initPlayerControl()
}
app = {
player:player
canvas:canvas
port:port
'navContent:navContent
controls:controls
paint:paintAll
handleEvents:loopEvents
onLeftKey:handleLeftKey
onUpKey:handleUpKey
onRightKey:handleRightKey
onDownKey:handleDownKey
onExitKey:handleExitKey
onOkKey:handleOkKey
}
return app
End Function
Function paintAll()
m.canvas.AllowUpdates(false)
m.canvas.Clear()
m.canvas.SetLayer(0, { Color: "#a6a663", CompositionMode: "Source" })
' Do, any painting here through the canvas object
for each k in m.controls
m.controls[k].paint(m.canvas)
end for
m.canvas.AllowUpdates(true)
m.canvas.Show()
End function
Function loopEvents()
while true
event = wait(0, m.port)
if (event<> invalid)
'print "events loop"
if (event.isRemoteKeyPressed())
index = event.GetIndex()
print index
if (index = 4) 'Left, pulls out the menu
m.onLeftKey()
else if (index = 2) 'Up
m.onUpKey()
else if (index = 5) 'Right,
m.onRightKey()
else if (index = 3) 'Down
m.onDownKey()
else if (index = 6) 'ok,
m.onOkKey()
else if (index = 0) 'Exit, exits app, if no control is visible
if(m.onExitKey() = 1)
ExitWhile
endif
endif
endif
endif
end while
End function
'If I had interfaces, this would become 'IUserInput'
Function handleLeftKey()
handled = false
for each k in m.controls
handled = m.controls[k].onLeftKey(m)
if(handled)
print 'handled!'
Exit For
end if
end for
end Function
Function handleUpKey()
for each k in m.controls
m.controls[k].onUpKey(m)
end for
end Function
Function handleRightKey()
for each k in m.controls
m.controls[k].onRightKey(m)
end for
end Function
Function handleDownKey()
for each k in m.controls
m.controls[k].onDownKey(m)
end for
end Function
Function handleExitKey()
for each k in m.controls
m.controls[k].onExitKey(m)
end for
return 1
end Function
Function handleOkKey()
for each k in m.controls
m.controls[k].onOkKey(m)
end for
end Function
' end of interface
Json playlist file example:
{"playlist":
[
{"title": "Channel One", "length": 0, "path": "http://www.playon.tv/online/iphone5/main.m3u8"},
{"title": "Channel Two", "length": 0, "path": "http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8"},
{"title": "Channel Three", "length": 0, "path": "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/sl.m3u8"},
{"title": "Channel Four", "length": 0, "path": "http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8"},
{"title": "Channel Five", "length": 0, "path": "http://184.72.239.149/vod/smil:BigBuckBunny.smil/playlist.m3u8"}
]
}