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)
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
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.
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.