0

Play/Resume single Button



HI I am trying to make a simple interactive where there are three buttons (up, Down and Play/pause) the user presses up and down to select a video they then push play/pause to play the selected video clip wile a video clip is playing the teacher (user) can push play/pause to pause the video so they can answer questions, they then push play/pause to resume the video. I have the menu system all sorted as this is something i have done often however i can not seam to figure a way to use one button to act as the play and pause/resume button. any ideas? i have been creating this using the latest Bright Author. Adam

7 comments

  • 0
    Avatar
    RokuLyndon


    Are you using brightauthor 2.3 beta, or 2.2?
    Currently, in brightauthor you can't use the same button for two different actions. So, either a custom script would be required, or some customization of the pause/resume command so it remembers the last setting used and does the opposite when it's called next.
  • 0
    Avatar
    Adam


    Thanks Lyndon

    I am using the latest beta.

    I guessed that a custom script was needed and so I begun looking through the Brightscript language.

    I have a basic Knowledge of C script from programming micro controllers but I can not figure out how to do what i need to in Brightscript.

    in C Script i would modify the Pause video command to be something like this (assuming a global variable of "Status=1" had been defined at the beginning of the script)

       else if command$ = "pauseVideoCommand" then
       
           if (Status == 1);    // Global variable defined at beginning of script. If statement to check if the status is 1 ie if it is in play mode (1 = Play 0 = Paused)
           {
           m.diagnostics.PrintDebug("Pause video")
           m.PauseVideo()
           Status = 0;   // set status to 0 ie Pause mode
           }
           else       // if status is not = 1 then it must be in pause mode  
           {
           m.diagnostics.PrintDebug("Resume video")
           m.ResumeVideo()
           Status = 1; // set status to 1 ie playing mode
           }

    Basically just using a global variable of "Status" to store either a 0 or 1 to represent the status of the video player (paused or playing) and then when the pauseVideoCommand is called cheching what the status is and sending either a pause or resume command to the video player

    would this kind of modification work (assuming i can get the language correct)? if not what would you suggest?
    I understand that Brightscript can not do Global Variables, is there a work around?
    I originally through instead of using the variable, to just poll the status of the roVideoPlayer when the button was pressed however i read on another forum topic that this can not be done.
    are you able to complete this for me? i am only really beginning with C script and my ability to read and understand programing language is still very limited.

    Thanks
    Adam
  • 0
    Avatar
    RokuLyndon


    You are correct in what you're trying to do. You can add values to an object that remain with that object throughout the execution of the script. So, the PauseVideo function belongs to the BSP object.  The m. reference you see is a pointer to the BSP object.

    So, you can create a variable called m.status. We just need to check test for m.status not existing. So, we would replace the contents of the pause command with the following:

     else if command$ = "pauseVideoCommand" then
       
           m.diagnostics.PrintDebug("Pause video")

    if m.status = invalid then m.status=0
    if m.status = 0 then
    m.pausevideo()
    m.status=1
    else if m.status=1 then
    m.resumevideo()
    m.status=0
    endif


  • 0
    Avatar
    Adam


    thanks Lyndon

    That worked great, good to know i wasnt too far off.

    could i also use this same method to create a toggle for Mute? (of course making the correct changes so that i pass the right parameters for mute on and mute off)
    would it work even if i was to change states between turning mute either on or off?

    also on a similar but different topic, i see that Brightauthor now has support for interactive menus, is there any plans for theses menus to be able to have a video as there background rather then just a image?

    Adam
  • 0
    Avatar
    RokuLyndon


    Yes, you could use it for toggling mute as well.

    I don't know if there are plans to make the interactive menu work over a video as the background. I'll put in a request.
  • 0
    Avatar
    Tracy
    Does this type of multistage button still require scripting or can it be done from the current version (April 2013) of BA?
  • 0
    Avatar
    Alex

    You can have 2 separate touch regions: 1 would be for pause, 1 for resume.

    You can use one gpio button or one usb button to accomplish pause/resume functionality.

    You can build such a presentation in BA.

    If this is not what you're looking for, please provide more details on what are you trying to do.

Please sign in to leave a comment.