Forum Discussion

Blackhawk's avatar
Blackhawk
Roku Guru
9 years ago

Live feed error

I'm making an live feed with ads yet theres Syntax Error on this code

' ********************************************************************

' ** Sample PlayVideo App

' ** Copyright (c) 2009 Roku Inc. All Rights Reserved.

' ********************************************************************

Function ShowLiveFeed() as integer

' 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

 

 

preroll = {

streamFormat: "mp4"

stream: {

url: "http://www.archive.org/download/kelloggs_variety_pak/kelloggs_variety_pak_512kb.mp4"

}

}

content ={

title: "TEDTalks : David Brooks: The social animal"

sdPosterURL: "https://images.ted.com/images/ted/78e8d94d1d2a81cd182e0626dc8e96a43c88d760_132x99.jpg"

hdPosterURL: "https://images.ted.com/images/ted/78e8d94d1d2a81cd182e0626dc8e96a43c88d760_132x99.jpg"

description: "Tapping into the findings of his latest book, NYTimes columnist David Brooks unpacks new insights into human nature from the cognitive sciences -- insights with massive implications for economics and politics as well as our own self-knowledge. In a talk full of humor, he shows how you can't hope to understand humans as separate individuals making choices based on their conscious awareness."

contentType: "episode"

streamFormat: "mp4"

stream: {

url: "http://video.ted.com/talks/podcast/DavidBrooks_2011.mp4"

}

}

 

playContent = true

while playContent

msg = Wait(0, videoPlayer.GetMessagePort())

currentAd = adIface.stitchedAdHandledEvent(msg, videoPlayer)



if currentAd <> Invalid and currentAd.evtHandled

' ad handled event, take no further action

if currentAd.adExited

' user exited, return to content selection

playContent = false

end if

else

' if no current ad or ad did not handle event, fall through to default event handling here

' ... Your application's usual event-handling code here ...

end if

end while

 

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

canvas.Close()

End Function

sub ShowVideoScreen(video)

port = CreateObject("roMessagePort")

screen = CreateObject("roVideoScreen")

screen.SetMessagePort(port)

screen.SetContent(video)

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 Function

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


How do I fix this?

14 Replies