kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
07:32 PM
Using Playduration for payment
I tried doing the following ... but not quite right I do not think ..... anyone have some input on what I should do ??
'Set Default screen values for items not in feed
item.HDBranded = false
item.IsHD = false
item.StarRating = "90"
item.ContentType = "episode"
item.cost = "0"
if item.cost = 0 then
item.PlayDuration = "60"
else
funds = tokenValidation()
if funds = 1 then
item.PlayDuration = item.PlayDuration
chargeCustomer()
else
item.PlayDuration = "0"
end if
end if
'media may be at multiple bitrates, so parse an build arrays
for idx = 0 to 4
e = curShow.media[idx]
if e <> invalid then
item.StreamBitrates.Push(strtoi(validstr(e.streamBitrate.GetText())))
item.StreamQualities.Push(validstr(e.streamQuality.GetText()))
item.StreamUrls.Push(validstr(e.streamUrl.GetText()))
endif
next idx
showCount = showCount + 1
feed.Push(item)
skipitem:
next
End Function
function tokenValidation() As Integer
sn = GetDeviceESN()
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://allbabestv.com/roku/getCredits.php?deviceID=" + sn)
response = xfer.GetToString()
xml = CreateObject("roXMLElement")
if xml.Parse(response)
if (xml.tokens > item.cost)
return 0
end if
end if
return 1
end function
function chargeCustomer()
sn = GetDeviceESN()
cost = item.cost
model = item.ContentId
xfer = CreateObject("roURLTransfer")
xfer.SetURL("http://allbabestv.com/roku/chargeCustomer.php?deviceID=" + sn + "&cost=" + cost + "&model=" + model)
response = xfer.GetToString()
end function
3 REPLIES 3

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
07:54 PM
Re: Using Playduration for payment
I don't know if it has anything to do with your issue (mainly, because it's not clear what you're trying to do), but both StarRating and PlayDuration should be integers, not strings.
Your code also tries to compare an item.cost value of "0" (string) with 0 (integer), which will always evaluate to false.
Your code also tries to compare an item.cost value of "0" (string) with 0 (integer), which will always evaluate to false.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
kooljay68
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
07:59 PM
Re: Using Playduration for payment
Thanks for the advice ...
What I am trying to do is offer a live stream in 5 min increments and charge a certain amount of tokens for them. So if they select a certain feed I want them to get charged and then get kicked after the time is up. if it is a preview it is free and lasts 60 seconds. and if they do not have enough tokens then I want play duration to be zero.
Does that help make it any clearer ??
What I am trying to do is offer a live stream in 5 min increments and charge a certain amount of tokens for them. So if they select a certain feed I want them to get charged and then get kicked after the time is up. if it is a preview it is free and lasts 60 seconds. and if they do not have enough tokens then I want play duration to be zero.
Does that help make it any clearer ??

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-09-2013
08:13 PM
Re: Using Playduration for payment
I still think part (most?) of your problem is the string vs. integer issue in your code. Also, if you're trying to reset PlayDuration to no longer have an effect, set it to invalid instead of "0".
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)