0

single pushbutton, 3 videos



A newbie that needs some pointers:

Using Hd2000, I want one pushbutton to control the unit. Each time the switch is closed, it should play the 'next' video, eg. video 1, video 2, video 3...

Do i need to do this with a script, or can it be done with a cvs file?

Other questions:
1. Does closing the switch, create a latch? that is, how do i tell the unit to ignore any more presses of the button until the video has quit playing....

I'm pouring through the info right now, but time is short, as in a day <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) -->, and any pointers would be a huge help!

thank you in advance....

4 comments

  • 0
    Avatar
    RokuLyndon


    Jeff,



    By buttons, are you referring to the GPIO input, because that's very easy to do using a CSV file. If you are talking about using the serial input, or buttons on a keyboard, that's also easy to do but requires a custom script. I can provide an example of either. You inidcated you are short on time.



    I'm including a sample autoplay.csv file. It lists 4 videos. When the script unit starts up, it will play a static image.



    With the csv file, you can use a single button to start playback. You can also use that single button to advance from the currently playing video to the next. But, if you want to wait until the video has stopped playing before using a button to play the next file, you would need to use x number of buttons, one for each video. After each video plays, it would return to a static image, and then pushing the corresponding button would play the video. This is if you want to use a csv file.



    To do this with a custom script, again, I'm going to need to know what kind of button you want to use, but assuming it's a GPIO button, one using the GPIO port, you could use the following script:



    I'm not sure what video mode you want to use, so I'm choosing 1280x720p, but that can be changed easily. The script is just a text file.



    So, the 4 button method for the csv file doesn't work, just unzip the autorun.bas, and put it on your flash card with your videos. Currently, the script supports up to 26 videos. This script reads files into the list. If there's a specific order you want your videos to play in, we can change the script to accomodate that.



    Please test the script thoroughly to make sure it performs as you expect it to. Let me know if you have any problems.



    I emailed you the files mentioned above. I'm including the script here:







    ----------------------Start of Script----------------------



    debug = true



    REM

    REM This script starts with a static image, intro.bmp.

    REM It then plays a list of videos one after the other when button 0 is pressed

    REM The script waits for the video to stop playing before it allows you to advance

    REM to the next video. When the end of the list is reached, pressing button 0

    REM starts at the top of the list again. After each video is played, the script

    REM returns to the static image.

    REM



    REM ******************************************************************

    REM Initialize Objects

    REM ******************************************************************

    REM Initialize Video & Button

       vid=CreateObject("roVideoPlayer")

       image=CreateObject("roImagePlayer")

       mode=CreateObject("roVideoMode")

       buttonpress=CreateObject("roGpioControlPort")

       p=CreateObject("roMessagePort")

       vid.SetPort(p)

       buttonpress.SetPort(p)





    REM *********************************************************************

    REM Set Constants

    REM *********************************************************************

    imagemode=1

    videomode$="1280x720x60p"



    default_image$="intro.bmp"

    vidend=8

    k=0

    number_of_videos=0

    vid_playing=false



    DIM videolist$(25)





    rem ---------------------------------

    mode.SetMode(videomode$)  

    image.SetDefaultMode(imagemode)





    rem

    rem Scan folder for videos and save to list

    l=ListDir("\")



    For i=1 to l.Count()

    file_name$ = l.RemoveHead()

    if right(file_name$, 4)=".mpg" or right(file_name$, 4)=".vob" then

    videolist$(k)=file_name$

    k=k+1

    if debug print "File name: "; file_name$; ". Number of videos: "; k

    endif

    Next



    number_of_videos=k

    k=0





    REM Start Demo ------------------------------------------

    REM Image plays first, and waits for input



    beginning:

    image.DisplayFile(default_image$)





    REM Now we wait for a button press..



    wait_for_button:

    If debug print "Waiting for a button to be pressed."

    msg=wait(0, p)



    if type(msg)="roGpioButton" then

    if debug print "A button has been pressed..."



      button = msg.GetInt()

    if button = 0 and vid_playing=false then    

    if debug print "Button 0 pressed, playing video."

    ok=vid.PlayFile(videolist$(k))

    vid_playing=true



    k=k+1

    if k=number_of_videos then k=0



    if ok=0 then

    print "An error occurred playing this file."

    STOP

    endif

    endif



    else if type(msg)="roVideoEvent" then

    status=msg.GetInt()

    if status = vidend then

    if debug print "Video has finished playing..."

    vid_playing=false

    goto beginning

    endif

    endif



    goto wait_for_button
  • 0
    Avatar
    RokuLyndon


    debug = true



    REM

    REM This script starts with a static image, intro.bmp.

    REM It then plays a list of videos one after the other when button 0 is pressed

    REM The script waits for the video to stop playing before it allows you to advance

    REM to the next video. When the end of the list is reached, pressing button 0

    REM starts at the top of the list again. After each video is played, the script

    REM returns to the static image.

    REM



    REM ******************************************************************

    REM Initialize Objects

    REM ******************************************************************

    REM Initialize Video & Button

       vid=CreateObject("roVideoPlayer")

       mode=CreateObject("roVideoMode")

       buttonpress=CreateObject("roGpioControlPort")

       p=CreateObject("roMessagePort")

       vid.SetPort(p)

       buttonpress.SetPort(p)





    REM *********************************************************************

    REM Set Constants

    REM *********************************************************************

    imagemode=1

    videomode$="1280x720x60p"



    vidend=8

    k=0

    number_of_videos=3

    vid_playing=false



    DIM videolist$(number_of_videos)

    videolist$(0)="video(0).mpg"

    videolist$(1)="video(1).mpg"

    videolist$(2)="video(2).mpg"





    rem ---------------------------------

    mode.SetMode(videomode$)  





    rem

    rem Enter Video names into array





    REM Start Demo

    REM Now we wait for a button press..



    wait_for_button:

    If debug print "Waiting for a button to be pressed."

    msg=wait(0, p)



    if type(msg)="roGpioButton" then

    if debug print "A button has been pressed, but not the correct button."



      button = msg.GetInt()

    if button = 0 and vid_playing=false then    

    if debug print "Button 0 pressed, playing video."

    ok=vid.PlayFile(videolist$(k))

    vid_playing=true



    k=k+1

    if k=number_of_videos then k=0



    if ok=0 then

    print "An error occurred playing this file."

    STOP

    endif

    endif



    else if type(msg)="roVideoEvent" then

    status=msg.GetInt()

    if status = vidend then

    if debug print "Video has finished playing..."

    vid_playing=false

    vid.StopClear()

    endif

    endif



    goto wait_for_button
  • 0
    Avatar
    ravasquez


    Can you substitute a keyboard button press instead of GPIO?

    Any key on the keyboard would work.

    Thanks
  • 0
    Avatar
    RokuLyndon


    Yes, you could make that substitution.



    We would define a keyboard object instead of GPIO.
Please sign in to leave a comment.