Pre-roll video question & Display Ads?

I read the blog entry about adding pre-roll video but where within the code does this snippet of code get added? Do I copy the code from the blog and paste it where?

Any help on adding pre-roll is appreciated.

Also, if you have added display ads to your posterscreens that can be changed from the server side, I appreciate some help with how to do this also.

Thanks in advance much!

The blog post has an email address in it. Email them and they’ll get back to you. I did the same thing recently and have preroll running in my channel with the code they supplied. You’ll want the VAST 1.05 code (not 1.01 which they originally sent) if you have doubleclick or CAST compatible ad server.

For the code on the blog post, the preroll function can go anywhere, the other code goes where you would normally have your video play.

I’m guessing here but this code from the blog entry… do I place it on the appdetails.brs? And, where does the url go for the pre-roll video?

function ShowPreRoll(video)
  ' a true result indicates that playback finished without user intervention
  ' a false result indicates that the user pressed UP or BACK to terminate playback
  result = true
  canvas = CreateObject("roImageCanvas")
  player = CreateObject("roVideoPlayer")
  port = CreateObject("roMessagePort")

  canvas.SetMessagePort(port)
  ' build a very simple buffer screen for our preroll video
  canvas.SetLayer(0, { text: "Your program will begin after this message" })
  canvas.Show()

  ' be sure to use the same message port for both the canvas and the player
  ' so we can receive events from both
  player.SetMessagePort(port)
  player.SetDestinationRect(canvas.GetCanvasRect())
  player.AddContent(video)

  player.Play()

  ' start our event loop
  while true
    ' wait for an event
    msg = wait(0, canvas.GetMessagePort())

    if type(msg) = "roVideoPlayerEvent"
      if msg.isFullResult()
        ' the video played to the end without user intervention
        exit while
      else if isRequestFailed()
        ' something went wrong with playback, but the user did not intervene
        exit while
      else if msg.isStatusMessage()
        if msg.GetMessage() = "start of play"
          ' once the video starts, clear out the canvas so it doesn't cover the video
          canvas.SetLayer(0, { color: "#00000000", CompositionMode: "Source" })
          canvas.Show()
        end if
      end if
    else if type(msg) = "roImageCanvasEvent"
      if msg.isRemoteKeyPressed()
        index = msg.GetIndex()
        if index = 0 or index = 2
          ' the user pressed UP or BACK to terminate playback
          result = false
          exit while
        end if
      end if
    end if
  end while

  player.Stop()
  canvas.Close()

  return result
end function

And where does this next part of the code go:

' create and display a blank roImageCanvas to prevent the
' underlying UI from flickering between videos
canvas = CreateObject("roImageCanvas")
canvas.SetLayer(0, "#000000")
canvas.Show()

' play the preroll video with trick play disabled
if ShowPreroll(preroll)
  ' only play the main content if the preroll completed without user intervention
  ShowVideoScreen(content)
end if

' close the blank canvas and return the user to the previous UI screen
canvas.Close()

The first section is a function, so it goes anywhere.
The second part requires a value for “video” before the function is used.
if ShowPreroll(preroll)

Preroll is defined above both parts of the code on the blog page.

The part that is not understood well is how to call or play our many videos that is in our xml files after the Pre-Roll video plays. Plus, better to call the Pre-Roll in a xml or php file as it is easier to change a pre-roll video than the hard coded part in the .brs files.
Any hints for that?

“bandal” wrote:
The part that is not understood well is how to call or play our many videos that is in our xml files after the Pre-Roll video plays. Plus, better to call the Pre-Roll in a xml or php file as it is easier to change a pre-roll video than the hard coded part in the .brs files.
Any hints for that?

Pulling the ad data from a cloud service and using it to construct a content-meta-data structure are left to the developer and not covered on the blog because that step could be different for each implementation. How to get an ad from your ad provider will depend on how the provider exposes their data to your channel.

Like milesplit said, If your ad provider supports VAST, we do have a BrightScript class that I can share for parsing VAST into a content-meta-data structure.

Regarding PreRoll I added the function for showPreroll into its own appPreRoll.brs file and in appVideoScreen.brs I have added this section, but always errors out on the line preroll = { line 142 in my script
Any idea why?
Debug shows this only but the Syntax I cant find an error:
*** ERROR compiling /pkg:/source/appVideoScreen.brs:
Syntax Error. (compile error &h02) in …kg:/source/appVideoScreen.brs(142)
.
.
.
preroll = {
streamFormat: “mp4”
stream: {
url: “http://www.archive.org/download/kelloggs_variety_pak/kelloggs_variety_pak_512kb.mp4
}
}
ShowVideoScreen(preroll)
port = CreateObject(“roMessagePort”)
screen = CreateObject(“roVideoScreen”)
screen.SetMessagePort(port)
screen.SetContent(preroll)

screen.Show()

while true
msg = wait(0, port)

if type(msg) = “roVideoScreenEvent”
if msg.isScreenClosed()
exit while
end if
end if
end while

screen.Close()
end sub
’ Create and display a blank roImageCanvas to prevent the
’ underlying UI from flickering between videos after Pre-Roll
canvas = CreateObject(“roImageCanvas”)
canvas.SetLayer(0, “#000000”)
canvas.Show()
’ Play the preroll video with trick play disabled

if ShowPreroll(preroll)

Function showVideoScreen(episode As Object)
'Start to Check if Billing was a successful************************
’ if (not BillReminder()) then return invalid
'End Check if Billing was successful*******************************
if type(episode) <> “roAssociativeArray” then
print “invalid data passed to showVideoScreen”
return -1
endif
'* Start optional Tracking of video content played****************
’ Track(episode[“contentId”])
'* End optional Tracking of video content played****************
port = CreateObject(“roMessagePort”)
screen = CreateObject(“roVideoScreen”)
screen.SetMessagePort(port)

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(0, port)

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
’ End Pre-Roll
End if
’ close the blank canvas and return the user to the previous UI screen
canvas.Close()

You can’t have a function inside another function or subroutine. It needs to be separate. I should have clarified ‘anywhere’ but I thought you knew that. Sorry for the confusion.
By anywhere - I mean, it makes no difference which brs file the function goes in, and it makes no difference where in whichever file you choose to place it provided a duplicate function or subroutine name doesn’t exist elsewhere, and that the function is not within another function or subroutine, as that isn’t a legal allowed coding scheme.

Ok, so the person who wrote the blog was mistaken then. So preroll is a function is what your saying?

I’m not quite sure - I haven’t read that blog entry in awhile. Some lines in your code you posted are not contained in a function or subroutine - and I don’t think it will work very well if you have code strewn about that way.

This code should work ok. (from simple poster screen example) - you will still need to parse your own xml data, but compare this to what you have and see where some lines have been moved.


' *********************************************************
' **  Simple Poster Screen Demonstration App
' **  Nov 2009
' **  Copyright (c) 2009 Roku Inc. All Rights Reserved.
' *********************************************************

'************************************************************
'** Application startup
'************************************************************
Sub Main()
    'initialize theme attributes like titles, logos and overhang color
    initTheme()
    'prepare the screen for display and get ready to begin
    screen=preShowPosterScreen("", "")
    if screen=invalid then
        print "unexpected error in preShowPosterScreen"
        return
    end if
    'set to go, time to get started
    showPosterScreen(screen)
End Sub

'*************************************************************
'** Set the configurable theme attributes for the application
'** 
'** Configure the custom overhang and Logo attributes
'** These attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************
Sub initTheme()
    app = CreateObject("roAppManager")
    theme = CreateObject("roAssociativeArray")
    theme.OverhangOffsetSD_X = "72"
    theme.OverhangOffsetSD_Y = "25"
    theme.OverhangSliceSD = "pkg:/images/Overhang_BackgroundSlice_Blue_SD43.png"
    theme.OverhangLogoSD  = "pkg:/images/Logo_Overhang_Roku_SDK_SD43.png"
    theme.OverhangOffsetHD_X = "123"
    theme.OverhangOffsetHD_Y = "48"
    theme.OverhangSliceHD = "pkg:/images/Overhang_BackgroundSlice_Blue_HD.png"
    theme.OverhangLogoHD  = "pkg:/images/Logo_Overhang_Roku_SDK_HD.png"
    app.SetTheme(theme)
End Sub

'******************************************************
'** Perform any startup/initialization stuff prior to 
'** initially showing the screen.  
'******************************************************
Function preShowPosterScreen(breadA=invalid, breadB=invalid) As Object
    port=CreateObject("roMessagePort")
    screen = CreateObject("roPosterScreen")
    screen.SetMessagePort(port)
    if breadA<>invalid and breadB<>invalid then
        screen.SetBreadcrumbText(breadA, breadB)
    end if
    screen.SetListStyle("arced-landscape")
    return screen
End Function

'******************************************************
'** Display the poster screen and wait for events from 
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the show posters
'******************************************************
Function showPosterScreen(screen As Object) As Integer
'SET UP PREROLL CONTENT
preroll={streamFormat: "mp4",stream: {url: "http://www.archive.org/download/kelloggs_variety_pak/kelloggs_variety_pak_512kb.mp4"}} 'added for preroll
'alternately you can parse your xml data here
'prerollseries=InitAdFeedConnection() 'load xml for preroll videos
'preroll=prerollseries[0] 'set preroll video to first advertisement in ad xml feed library
'END OF PREROLL CONTENT

    categoryList = getCategoryList()
    screen.SetListNames(categoryList)
    iSelected=0
    CurrentContent=getShowsForCategoryItem(categoryList[0])
    screen.SetContentList(CurrentContent)
    screen.Show()
    while true
        msg = wait(0, screen.GetMessagePort())
        if type(msg) = "roPosterScreenEvent" then
            print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
            if msg.isListFocused() then
                'get the list of shows for the currently selected item
                iSelected=0
                CurrentContent=getShowsForCategoryItem(categoryList[msg.GetIndex()])
                screen.SetContentList(CurrentContent)
                print "list focused | current category = "; msg.GetIndex()
            else if msg.isListItemFocused() then
                print"list item focused | current show = "; msg.GetIndex()
                iSelected=msg.GetIndex()
            else if msg.isListItemSelected() then

'INSERTED PREROLL CODE
                ' create and display a blank roImageCanvas to prevent the
                ' underlying UI from flickering between videos
                CanvasBlock=CreateObject("roImageCanvas")
                CanvasBlock.SetLayer(0,"#000000")
                CanvasBlock.Show()
                ' play the preroll video with trick play disabled
                If ShowPreroll(preroll)
                    ' only play the main content if the preroll completed without user intervention
                    PlayVideo(CurrentContent[iSelected])
                End If
		' close the blank canvas and return the user to the previous UI screen
		CanvasBlock.Close()
'END OF PREROLL CODE INSERTION

            else if msg.isScreenClosed() then
                return -1
            end if
        end If
    end while
End Function

'PREROLL FUNCTION
Function ShowPreRoll(video) As Boolean
	' a true result indicates that playback finished without user intervention
	' a false result indicates that the user pressed UP or BACK to terminate playback
	Result=True
	CanvasPreroll=CreateObject("roImageCanvas")
	PlayerPreRoll=CreateObject("roVideoPlayer")
	Port=CreateObject("roMessagePort")
	
	CanvasPreroll.SetMessagePort(Port)
	' build a very simple buffer screen for our preroll video
	CanvasPreroll.SetLayer(0, { text: "Your program will begin after this message" })
	CanvasPreroll.Show()
	
	' be sure to use the same message port for both the canvas and the player
	' so we can receive events from both
	PlayerPreRoll.SetMessagePort(Port)
	PlayerPreRoll.SetDestinationRect(CanvasPreroll.GetCanvasRect())
	PlayerPreRoll.AddContent(video)
	PlayerPreRoll.Play()
	' start our event loop
	While True
		' wait for an event
		msg=Wait(0, CanvasPreroll.GetMessagePort())
		If Type(msg)="roVideoPlayerEvent"
			If msg.isFullResult()
				' the video played to the end without user intervention
				Exit While
			Else If msg.isRequestFailed()
				' something went wrong with playback, but the user did not intervene
				Exit While
			Else If msg.isStatusMessage()
				If msg.GetMessage()="start of play"
					' once the video starts, clear out the canvas so it doesn't cover the video
					CanvasPreroll.SetLayer(0, { color: "#00000000", CompositionMode: "Source" })
					CanvasPreroll.Show()
				End If
			End If
		Else If type(msg)="roImageCanvasEvent"
			If msg.isRemoteKeyPressed()
				index=msg.GetIndex()
				If index=0 Or index=2
					' the user pressed UP or BACK to terminate playback
					Result=False
					Exit While
				End If
			End If
		End If
	End While
	
	PlayerPreRoll.Stop()
	CanvasPreroll.Close()
	
	Return Result
End Function
'END OF PREROLL FUNCTION

'***** VIDEO PLAYBACK *****
'This will only work if you have valid streaming show data
Function PlayVideo(CurrentVideo As Object)
	port=CreateObject("roMessagePort")
	screen=CreateObject("roVideoScreen")
	screen.SetMessagePort(port)
	screen.SetContent(CurrentVideo)
	screen.Show()
	While TRUE
		msg=Wait(0,port)
		If Type(msg)="roVideoScreenEvent"
			'Print"showHomeScreen | msg = ";msg.getMessage();" | index = ";msg.GetIndex()
			If msg.isScreenClosed()
			'	Print"Screen closed"
				Exit While
			Else If msg.isRequestFailed()
				Print"Video request failure: ";msg.GetIndex();" ";msg.GetMessage() 
			Else If msg.isStatusMessage()
				Print"Video status: ";msg.GetIndex();" ";msg.GetData() 
				If msg.GetIndex()=0 And msg.GetData()=0
					print "Error With encode, we assume it played the full video"
					Exit While
				End If
			Else If msg.isButtonPressed()
				Print"Button pressed: ";msg.GetIndex();" ";msg.GetData()
			Else If msg.isFullResult() 'played full video
				print "Full Result"
				Exit While
			Else If msg.isPartialResult()
				print "Partial Result"
				Exit While
			Else
				Print"Unexpected event type: ";msg.GetType()
			End If
		Else
			Print"Unexpected message class: ";Type(msg)
		End If
	End While
End Function

'**************************************************************
'** Return the list of categories to display in the filter
'** banner. The result is an roArray containing the names of 
'** all of the categories. All just static data for the example.
'***************************************************************
Function getCategoryList() As Object
    categoryList = CreateObject("roArray", 10, true)
    categoryList = [ "Comedy", "Drama", "News", "Reality", "Daytime"  ]
    return categoryList
End Function

'********************************************************************
'** Given the category from the filter banner, return an array 
'** of ContentMetaData objects (roAssociativeArray's) representing 
'** the shows for the category. For this example, we just cheat and
'** create and return a static array with just the minimal items
'** set, but ideally, you'd go to a feed service, fetch and parse
'** this data dynamically, so content for each category is dynamic
'********************************************************************
Function getShowsForCategoryItem(category As Object) As Object
    print "getting shows for category "; category
    showList = [
        {
            ShortDescriptionLine1:"Show #1",
            ShortDescriptionLine2:"Short Description for Show #1",
        }
        {
            ShortDescriptionLine1:"Show #2",
            ShortDescriptionLine2:"Short Description for Show #2",
            HDPosterUrl:"pkg:/media/bogusFileName_hd.jpg",
            SDPosterUrl:"pkg:/media/bogusFileName_hd.jpg"
        }
        {
            ShortDescriptionLine1:"Show #3",
            ShortDescriptionLine2:"Short Description for Show #3",
        }
    ]
return showList
End Function

Thanks for the post, I will be busy examining it and see how it works within my code.

DA

Same here. Going to read over the posts and try to catch up. I was not able to work on the channel yesterday.

Thanks a bunch.

I’m getting back to wok on the pre-roll again after working on different parts of the channel. Trying to see what step one is to making the pre-roll work. Going to take time to back track and start from scratch to see if this code will work for me. I haven’t had time to work on the pre-roll recently until now.

destruk, the code you provided, I should put this into it’s own brs file, is this correct?

' *********************************************************
' **  Simple Poster Screen Demonstration App
' **  Nov 2009
' **  Copyright (c) 2009 Roku Inc. All Rights Reserved.
' *********************************************************

'************************************************************
'** Application startup
'************************************************************
Sub Main()
    'initialize theme attributes like titles, logos and overhang color
    initTheme()
    'prepare the screen for display and get ready to begin
    screen=preShowPosterScreen("", "")
    if screen=invalid then
        print "unexpected error in preShowPosterScreen"
        return
    end if
    'set to go, time to get started
    showPosterScreen(screen)
End Sub

'*************************************************************
'** Set the configurable theme attributes for the application
'** 
'** Configure the custom overhang and Logo attributes
'** These attributes affect the branding of the application
'** and are artwork, colors and offsets specific to the app
'*************************************************************
Sub initTheme()
    app = CreateObject("roAppManager")
    theme = CreateObject("roAssociativeArray")
    theme.OverhangOffsetSD_X = "72"
    theme.OverhangOffsetSD_Y = "25"
    theme.OverhangSliceSD = "pkg:/images/Overhang_BackgroundSlice_Blue_SD43.png"
    theme.OverhangLogoSD  = "pkg:/images/Logo_Overhang_Roku_SDK_SD43.png"
    theme.OverhangOffsetHD_X = "123"
    theme.OverhangOffsetHD_Y = "48"
    theme.OverhangSliceHD = "pkg:/images/Overhang_BackgroundSlice_Blue_HD.png"
    theme.OverhangLogoHD  = "pkg:/images/Logo_Overhang_Roku_SDK_HD.png"
    app.SetTheme(theme)
End Sub

'******************************************************
'** Perform any startup/initialization stuff prior to 
'** initially showing the screen.  
'******************************************************
Function preShowPosterScreen(breadA=invalid, breadB=invalid) As Object
    port=CreateObject("roMessagePort")
    screen = CreateObject("roPosterScreen")
    screen.SetMessagePort(port)
    if breadA<>invalid and breadB<>invalid then
        screen.SetBreadcrumbText(breadA, breadB)
    end if
    screen.SetListStyle("arced-landscape")
    return screen
End Function

'******************************************************
'** Display the poster screen and wait for events from 
'** the screen. The screen will show retreiving while
'** we fetch and parse the feeds for the show posters
'******************************************************
Function showPosterScreen(screen As Object) As Integer
'SET UP PREROLL CONTENT
preroll={streamFormat: "mp4",stream: {url: "http://www.archive.org/download/kelloggs_variety_pak/kelloggs_variety_pak_512kb.mp4"}} 'added for preroll
'alternately you can parse your xml data here
'prerollseries=InitAdFeedConnection() 'load xml for preroll videos
'preroll=prerollseries[0] 'set preroll video to first advertisement in ad xml feed library
'END OF PREROLL CONTENT

    categoryList = getCategoryList()
    screen.SetListNames(categoryList)
    iSelected=0
    CurrentContent=getShowsForCategoryItem(categoryList[0])
    screen.SetContentList(CurrentContent)
    screen.Show()
    while true
        msg = wait(0, screen.GetMessagePort())
        if type(msg) = "roPosterScreenEvent" then
            print "showPosterScreen | msg = "; msg.GetMessage() " | index = "; msg.GetIndex()
            if msg.isListFocused() then
                'get the list of shows for the currently selected item
                iSelected=0
                CurrentContent=getShowsForCategoryItem(categoryList[msg.GetIndex()])
                screen.SetContentList(CurrentContent)
                print "list focused | current category = "; msg.GetIndex()
            else if msg.isListItemFocused() then
                print"list item focused | current show = "; msg.GetIndex()
                iSelected=msg.GetIndex()
            else if msg.isListItemSelected() then

'INSERTED PREROLL CODE
                ' create and display a blank roImageCanvas to prevent the
                ' underlying UI from flickering between videos
                CanvasBlock=CreateObject("roImageCanvas")
                CanvasBlock.SetLayer(0,"#000000")
                CanvasBlock.Show()
                ' play the preroll video with trick play disabled
                If ShowPreroll(preroll)
                    ' only play the main content if the preroll completed without user intervention
                    PlayVideo(CurrentContent[iSelected])
                End If
      ' close the blank canvas and return the user to the previous UI screen
      CanvasBlock.Close()
'END OF PREROLL CODE INSERTION

            else if msg.isScreenClosed() then
                return -1
            end if
        end If
    end while
End Function

'PREROLL FUNCTION
Function ShowPreRoll(video) As Boolean
   ' a true result indicates that playback finished without user intervention
   ' a false result indicates that the user pressed UP or BACK to terminate playback
   Result=True
   CanvasPreroll=CreateObject("roImageCanvas")
   PlayerPreRoll=CreateObject("roVideoPlayer")
   Port=CreateObject("roMessagePort")
   
   CanvasPreroll.SetMessagePort(Port)
   ' build a very simple buffer screen for our preroll video
   CanvasPreroll.SetLayer(0, { text: "Your program will begin after this message" })
   CanvasPreroll.Show()
   
   ' be sure to use the same message port for both the canvas and the player
   ' so we can receive events from both
   PlayerPreRoll.SetMessagePort(Port)
   PlayerPreRoll.SetDestinationRect(CanvasPreroll.GetCanvasRect())
   PlayerPreRoll.AddContent(video)
   PlayerPreRoll.Play()
   ' start our event loop
   While True
      ' wait for an event
      msg=Wait(0, CanvasPreroll.GetMessagePort())
      If Type(msg)="roVideoPlayerEvent"
         If msg.isFullResult()
            ' the video played to the end without user intervention
            Exit While
         Else If msg.isRequestFailed()
            ' something went wrong with playback, but the user did not intervene
            Exit While
         Else If msg.isStatusMessage()
            If msg.GetMessage()="start of play"
               ' once the video starts, clear out the canvas so it doesn't cover the video
               CanvasPreroll.SetLayer(0, { color: "#00000000", CompositionMode: "Source" })
               CanvasPreroll.Show()
            End If
         End If
      Else If type(msg)="roImageCanvasEvent"
         If msg.isRemoteKeyPressed()
            index=msg.GetIndex()
            If index=0 Or index=2
               ' the user pressed UP or BACK to terminate playback
               Result=False
               Exit While
            End If
         End If
      End If
   End While
   
   PlayerPreRoll.Stop()
   CanvasPreroll.Close()
   
   Return Result
End Function
'END OF PREROLL FUNCTION

'***** VIDEO PLAYBACK *****
'This will only work if you have valid streaming show data
Function PlayVideo(CurrentVideo As Object)
   port=CreateObject("roMessagePort")
   screen=CreateObject("roVideoScreen")
   screen.SetMessagePort(port)
   screen.SetContent(CurrentVideo)
   screen.Show()
   While TRUE
      msg=Wait(0,port)
      If Type(msg)="roVideoScreenEvent"
         'Print"showHomeScreen | msg = ";msg.getMessage();" | index = ";msg.GetIndex()
         If msg.isScreenClosed()
         '   Print"Screen closed"
            Exit While
         Else If msg.isRequestFailed()
            Print"Video request failure: ";msg.GetIndex();" ";msg.GetMessage() 
         Else If msg.isStatusMessage()
            Print"Video status: ";msg.GetIndex();" ";msg.GetData() 
            If msg.GetIndex()=0 And msg.GetData()=0
               print "Error With encode, we assume it played the full video"
               Exit While
            End If
         Else If msg.isButtonPressed()
            Print"Button pressed: ";msg.GetIndex();" ";msg.GetData()
         Else If msg.isFullResult() 'played full video
            print "Full Result"
            Exit While
         Else If msg.isPartialResult()
            print "Partial Result"
            Exit While
         Else
            Print"Unexpected event type: ";msg.GetType()
         End If
      Else
         Print"Unexpected message class: ";Type(msg)
      End If
   End While
End Function

'**************************************************************
'** Return the list of categories to display in the filter
'** banner. The result is an roArray containing the names of 
'** all of the categories. All just static data for the example.
'***************************************************************
Function getCategoryList() As Object
    categoryList = CreateObject("roArray", 10, true)
    categoryList = [ "Comedy", "Drama", "News", "Reality", "Daytime"  ]
    return categoryList
End Function

'********************************************************************
'** Given the category from the filter banner, return an array 
'** of ContentMetaData objects (roAssociativeArray's) representing 
'** the shows for the category. For this example, we just cheat and
'** create and return a static array with just the minimal items
'** set, but ideally, you'd go to a feed service, fetch and parse
'** this data dynamically, so content for each category is dynamic
'********************************************************************
Function getShowsForCategoryItem(category As Object) As Object
    print "getting shows for category "; category
    showList = [
        {
            ShortDescriptionLine1:"Show #1",
            ShortDescriptionLine2:"Short Description for Show #1",
        }
        {
            ShortDescriptionLine1:"Show #2",
            ShortDescriptionLine2:"Short Description for Show #2",
            HDPosterUrl:"pkg:/media/bogusFileName_hd.jpg",
            SDPosterUrl:"pkg:/media/bogusFileName_hd.jpg"
        }
        {
            ShortDescriptionLine1:"Show #3",
            ShortDescriptionLine2:"Short Description for Show #3",
        }
    ]
return showList
End Function

um…I think so? as long as the routine names aren’t used in other files it should be ok.

Any one have pre-roll working running their own pre-roll content versus using a service? I have my own content I want to add but have not been able to get pre-roll working.

If anyone can share, it sure would be nice.

What XML is proper to use for picking and choosing which pre-roll add play? I have different ones for certain videos.

With the above coding in this post that destruk has provided and placed into a preroll.brs file…

What’s missing?

Thank you.

Where do I put this?

shouldPlayContent = true 

adBreakIndex = 0 

while shouldPlayContent

videoMsg = wait(0, contentVideoScreen.GetMessagePort())

if videoMsg.isPlaybackPosition()

curPos = videoMsg.GetIndex()

nextPod = scheduledPods[adBreakIndex]

if curPos > nextPod.renderTime and not nextPod.viewed

contentVideoScreen.Close() 

' stop playback of content

shouldPlayContent = adIface.showAds(nextPod) 

' render next ad pod

adBreakIndex = adBreakIndex + 1

if shouldPlayContent

' *** Insert client app’s resume-playback code here

end if

end if

end if

' *** Insert client app’s video event handler code here 

 

end while

' close the blank canvas and return the user to the previous UI screen

canvas.Close()