Forum Discussion

uarlive's avatar
uarlive
Visitor
12 years ago

advertisement countdown

I am trying to get the duration of the ad to count down on the screen. Below is the code that I have working so far. The number of seconds is currently static and should be dymanic. Thanks in advance.


function ShowPreRoll(canvas, ad)
result = true

player = CreateObject("roVideoPlayer")
' be sure to use the same message port for both the canvas and the player
player.SetMessagePort(canvas.GetMessagePort())
player.SetDestinationRect(canvas.GetCanvasRect())
player.SetPositionNotificationPeriod(1)
timer = CreateObject("roTimespan")
timer.mark()
--> Problem area ad_duration = ad.length - timer

' set up some messaging to display while the pre-roll buffers

deviceInfo = CreateObject( "roDeviceInfo" )
displaySize = deviceInfo.GetDisplaySize()



overlay = {
TargetRect: {
x: Int( displaySize.w / 2 ) - Int( 336 / 2 ),
y: Int( displaySize.h / 2 ) - Int( 375 / 2 ),
w: 336,
h: 210
}
}

loadingText = {
--> Problem area Text: "Your video will begin after this message" + ad_duration.ToStr() + " seconds",
TextAttrs: {
Font: "Medium",
VAlign: "Bottom",
Color: "#FFFFFF",
},
TargetRect: {
x: Int( displaySize.w / 2 ) - Int( 1180 / 2 ),
y: Int( displaySize.h / 2 ) - Int( -600 / 2 ),
w: 575,
h: 30
}
}
canvas.Show()


Type Mismatch. (runtime error &h18) in ...:/source/VAST_VideoScreen.brs(52)

052: ad_duration = ad.length - timer
Backtrace:

2 Replies

  • destruk's avatar
    destruk
    Streaming Star
    "timer" is an object, you are trying to subtract it as an integer, but it isn't an integer.

    Integer TotalSeconds(Void)
    • Returns the total number of seconds from the “Mark” point.

    You should be subtracting timer.totalseconds() which returns as an integer.

    Even using that though, you'll want to loop it or nest it inside a routine so it will constantly repeat the subtraction and display until it reaches 0.