Forum Discussion

Blackhawk's avatar
Blackhawk
Roku Guru
9 years ago

On demand menu

I was setting up a demand menu
Function CreateBonanzaMenu() as integer

screen = CreateObject("roPosterScreen")

port = CreateObject("roMessagePort")

screen.SetMessagePort(port)



screen.SetBreadcrumbText("Bonanza", "Full Menu")

screen.SetContentList(GetBonanzaEpisodes())

screen.SetFocusedListItem(4)

screen.show()



while (true)

msg = wait(0, port)

if type(msg) = "roPosterScreenEvent"

if (msg.isScreenClosed())

return -1

else if (msg.isListItemSelected())

ShowBonanzaEpisodeDetails( msg.GetIndex() )

endif

endif



end while

End Function

Function GetBonanzaEpisodes() as object

m.options = [

{

EpisodeTitle: "Bitter Water"

EpisodeDescription: "The Cartwrights find themselves involved in a fight over water rights, when the son of one of their neighbors is influenced by the father of his fiancee. Lem Keith wants to destroy the Ponderosa and will stop at nothing including infecting Ponderosa cattle with his own diseased cattle. This leads the Cartwrights to take measures that they never thought they would use."

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

{

EpisodeTitle: "Blood On The Land"

EpisodeDescription: "A sheepherder and his men try to drive their sheep across the Ponderosa. Ben and Adam disagree about how to stop them. Ben wants the Cartwrights to handle their own matters, Adam wants to let the law handle the situation. After Adam is taken hostage, Ben starts to see things Adam's way."

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

{

EpisodeTitle: "Dark Star"

EpisodeDescription: "Joe is about to shoot what he thinks is a wolf and discovers it is a woman. The woman turns out to be a gypsy, who her people think is possessed by the devil. Joe falls in love and she is taken in by the Cartwrights after her family shuns her. Joe is determined to find out what is really going on behind the strange happenings that are blamed on the woman."

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

{

EpisodeTitle: "Death At Dawn"

EpisodeDescription: "The town is being run by bad guys and the Cartwrights decide it has to stop. When a local merchant is gunned down for refusing to pay protection, Farmer Perkins is tried and sentenced to hang. Ben is taken hostage by Perkins' employer, with threats to hang Ben if Farmer is not released. "

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

{

EpisodeTitle: ""

EpisodeDescription: ""

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

{

EpisodeTitle: ""

EpisodeDescription: ""

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

{

EpisodeTitle: ""

EpisodeDescription: ""

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}



{

EpisodeTitle: ""

EpisodeDescription: ""

SDPosterURL: "pkg://images/.png"

HDPosterURL: "pkg://images/.png"

}

]

return m.options

End Function

Function ShowBonanzaEpisodeDetails(index as integer) as integer

print "Selected Index: " + Stri(index)

detailsScreen = CreateObject("roSpringboardScreen")

port = CreateObject("roMessagePort")

detailsScreen.SetMessagePort(port)

detailsScreen.SetDescriptionStyle("generic")

detailsScreen.SetBreadcrumbText("Bonanza", m.options[index].EpisodeTitle)

detailsScreen.SetStaticRatingEnabled(false)



details = {

HDPosterUrl: m.options[index].HDPosterURL

SDPosterUrl: m.options[index].SDPosterURL

EpisodeTitle: m.options[index].EpisodeTitle

EpisodeDescription: m.options[index].EpisodeDescription

}

detailsScreen.SetContent(details)

detailsScreen.AddButton(1, "Play Episode")

detailsScreen.show()



while (true)

msg = wait(0, port)

if type(msg) = "roSpringboardScreenEvent"

if (msg.isScreenClosed())

return -1

else if (msg.isButtonPressed())

DetailsScreenButtonClicked( msg.GetIndex() )

endif

endif

end while

End Function

Function DetailsScreenButtonClicked(index as integer) as void

dialog = CreateObject("roOneLineDialog")

if (index = 1)

PlayVideo()

endif

dialog.ShowBusyAnimation()

dialog.show()



Sleep(4000)

End Function

Function PlayVideo(index as integer) as void

if (index = 0)

videoContent = {

streamFormat: "mp4"

stream: {

url: "https://archive.org/download/Bonanza-BitterWater/Bonanza_Bitter_Water_S01-E29_512kb.mp4"

}

}

else if

videoContent = {

streamFormat: "mp4"

stream: {

url: "https://archive.org/download/Bonanza-BloodOnTheLand/Bonanza_-_Blood_On_The_Land_S01-E22_512kb.mp4"

}

}

else if

videoContent = {

streamFormat: "mp4"

stream: {

url: "https://archive.org/download/Bonanza-DarkStar/Bonanza_-_Dark_Star_S01-E31_512kb.mp4"

}

}

else if

videoContent = {

streamFormat: "mp4"

stream: {

url: "https://archive.org/download/Bonanza-DeathAtDawn/Bonanza_-_Death_At_Dawn_S01-E32_512kb.mp4"

}

}

else if

videoContent = {

streamFormat: "mp4"

stream: {

url: "https://archive.org/download/Bonanza-DeathAtDawn/Bonanza_-_Death_At_Dawn_S01-E32_512kb.mp4"

}

}

end if

PlayContentWithFullRAFIntegration(videoContent)

 

End Function



I keep getting syntax errors (132, 140, 148, 156, 164) on the code

5 Replies

  • I'm sure someone would like to help, but I doubt anyone is going to count down 132 lines to start figuring it out.  Maybe Add some line #'s.
  • See the question marks? You kind of have to say something there
    ...
    else if ' ???????????????????? '
    videoContent = {
    streamFormat: "mp4"
    stream: {
    url: "https://archive.org/download/Bonanza-BloodOnTheLand/Bonanza_-_Blood_On_The_Land_S01-E22_512kb.mp4"
    }
    }
    else if ' ???????????????????? '
    videoContent = {
    streamFormat: "mp4"
    stream: {
    url: "https://archive.org/download/Bonanza-DarkStar/Bonanza_-_Dark_Star_S01-E31_512kb.mp4"
    }


    Side note: more than one syntax error? Ha, curious - seems the compiler bothers doing some parsing error recovery! I wouldn't've bothered
  • I had changed the code to this

    Function PlayVideo(index as integer) as void

    videoContent = {

    streamFormat: "mp4"

    stream: {

    if (index = 0)

    url: "https://archive.org/download/Bonanza-BitterWater/Bonanza_Bitter_Water_S01-E29_512kb.mp4"

    else if (index = 1)

    url: "https://archive.org/download/Bonanza-BloodOnTheLand/Bonanza_-_Blood_On_The_Land_S01-E22_512kb.mp4"

    else if (index = 2)

    url: "https://archive.org/download/Bonanza-DarkStar/Bonanza_-_Dark_Star_S01-E31_512kb.mp4"

    else if (index = 3)

    url: "https://archive.org/download/Bonanza-DeathAtDawn/Bonanza_-_Death_At_Dawn_S01-E32_512kb.mp4"

    end if

    }

    }

    PlayContentWithFullRAFIntegration(videoContent)



    End Function


    Yet theres error (125, 127, 129, 131) how can I fix this
  • I don't believe that's valid syntax, as far as I know, you can't do conditional field assignment like you're trying to.

    Create the url variable outside of the definition, and then assign it when it's "ready"

    Function PlayVideo(index as integer) as void

    theUrl = invalid
     if (index = 0) then
     theUrl = "https://archive.org/download/Bonanza-BitterWater/Bonanza_Bitter_Water_S01-E29_512kb.mp4"
     else if (index = 1) then
     theUrl = "https://archive.org/download/Bonanza-BloodOnTheLand/Bonanza_-_Blood_On_The_Land_S01-E22_512kb.mp4"
     else if (index = 2) then
     theUrl = "https://archive.org/download/Bonanza-DarkStar/Bonanza_-_Dark_Star_S01-E31_512kb.mp4"
     else if (index = 3) then
     theUrl = "https://archive.org/download/Bonanza-DeathAtDawn/Bonanza_-_Death_At_Dawn_S01-E32_512kb.mp4"
    else
    print "Invalid index"
     theUrl = invalid
    end if
    if (theUrl <> invalid) then
     videoContent = {
       streamFormat: "mp4"
       stream: {
         url: theUrl
       }
     }
     PlayContentWithFullRAFIntegration(videoContent)
    else
     ' Some error-handling code?
    end if
    End Function