Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
kooljay68
Visitor

roVideoScreen - Code need some help please look ?

roVideoScreen ..... Can anyone give me some insight as to why this might not be working?


'**********************************************************
'** Video Player Example Application - Video Playback
'** November 2009
'** Copyright (c) 2009 Roku Inc. All Rights Reserved.
'**********************************************************

'***********************************************************
'** Create and show the video screen. The video screen is
'** a special full screen video playback component. It
'** handles most of the keypresses automatically and our
'** job is primarily to make sure it has the correct data
'** at startup. We will receive event back on progress and
'** error conditions so it's important to monitor these to
'** understand what's going on, especially in the case of errors
'***********************************************************
Function showVideoScreen(episode As Object)

if type(episode) <> "roAssociativeArray" then
print "invalid data passed to showVideoScreen"
return -1
endif

port = CreateObject("roMessagePort")
screen = CreateObject("roVideoScreen")
screen.SetMessagePort(port)

screen.Show()
screen.SetPositionNotificationPeriod(30)
screen.SetContent(episode)
screen.Show()

'Uncomment his line to dump the contents of the episode to be played
'PrintAA(episode)

while true
msg = wait(100, port)

if m.cost = 25 then
funds = tokenValidation()
if funds = 1 then
exit while
else
chargeCustomer()
end if
end if

if type(msg) = "roVideoScreenEvent" then
print "showHomeScreen | msg = "; msg.getMessage() " | index = "; msg.GetIndex()
if msg.isScreenClosed()
print "Screen closed"
exit while
elseif msg.isRequestFailed()
print "Video request failure: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isStatusMessage()
print "Video status: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isButtonPressed()
print "Button pressed: "; msg.GetIndex(); " " msg.GetData()
elseif msg.isPlaybackPosition() then
nowpos = msg.GetIndex()
RegWrite(episode.ContentId, nowpos.toStr())
else
print "Unexpected event type: "; msg.GetType()
end if
else
print "Unexpected message class: "; type(msg)
end if
end while

End Function


Function tokenValidation()
sn = GetDeviceESN()
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://allbabestv.com/mcams/roku/getCredits.php?deviceID=" + sn)
response = xfer.GetToString()
xml = CreateObject("roXMLElement")
if xml.Parse(response)
if (strtoi(xml.tokens) > m.cost)
return 0
end if
end if
return 1
end Function


Function chargeCustomer()
sn = GetDeviceESN()
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://allbabestv.com/mcams/roku/chargeCustomer.php?deviceID=" + sn + "&cost=" + m.cost + "&model=" + m.model)
response = xfer.GetToString()
end Function
0 Kudos
5 REPLIES 5
RokuMarkn
Visitor

Re: roVideoScreen - Code need some help please look ?

While it's possible to study a piece of code and determine what's wrong with it, it would be a lot easier if you posted more information, like exactly in what way it is not working (compile error, runtime error, misbehavior, ...?), what messages you see on the debugger if it does run, and what you've done so far to try to debug it.

--Mark
0 Kudos
kooljay68
Visitor

Re: roVideoScreen - Code need some help please look ?

Sorry ... ok ... it doesn't seem like the m.cost value is being passed to the off statement:

while true
msg = wait(100, port)

if m.cost = 25 then
funds = tokenValidation()
if funds = 1 then
exit while
else
chargeCustomer()
end if
end if
0 Kudos
RokuMarkn
Visitor

Re: roVideoScreen - Code need some help please look ?

Well, I don't see anywhere in the code you posted where you are setting m.cost. Are you setting it somewhere else?

If you suspect that's the problem, you could add a print statement to confirm the value of m.cost before you use it.

--Mark
0 Kudos
kooljay68
Visitor

Re: roVideoScreen - Code need some help please look ?

ok ... I am using debug mode ....

do I just do:

print m.cost

because all I get is -- invalid
0 Kudos
kooljay68
Visitor

Re: roVideoScreen - Code need some help please look ?

using print "cost "; m.cost

I get the following debug message: cost invalid


but when I set them in showFeed.brs

item.cost = strtoi(item.cost)
item.modelId = strtoi(item.modelId)

m.cost = item.cost
m.model = item.modelId

print "cost "; m.cost
print "model "; m.model

the debug shows the correct values:

cost 25
model 22
0 Kudos