0

usb keyboard control



I have an HD 600 that I want to use as a clip player for local news but I can not seem to make the unit controllable by USB keyboard. Am I doing something wrong or am I trying to do the impossible?

10 comments

  • 0
    Avatar
    RokuLyndon


    Hi,



    How are you trying to playback your content? USB keyboard support isn't built into interactive playlists, so a custom script would be needed. Can you explain how you're trying to playback content.
  • 0
    Avatar
    chadmy


    I want my director to be able to hit a button on a keyboard and have a clip play.
  • 0
    Avatar
    RokuLyndon


    This can be done, but it requires a custom script, but not a complicated. Each key press has a numerical value, but we can use a builtin function to lookup the actual letter or number pressed. For example:



    v = CreateObject("roVideoPlayer")

    kb = CreateObject("roKeyboard")

    p = CreateObject("roMessagePort")

    v.SetPort(p)

    kb.SetPort(p)



    Wait_for_input:

    msg = wait(0,p)

    if type (msg) = "roKeyboardPress" then

      if chr(msg) = p then v.PlayFile("video1.mpg")

    endif

    goto Wait_for_input



    ----end of script-------



    This example plays video 1 if the letter R is pressed.



    To help more, I'd need more details. How many videos? Which keyboard keys do you want to use? Are the videos playing just once? Should you be able to interrupt the videos?
  • 0
    Avatar
    chadmy


    I want to have 15-20 videos available to play, I want the videos to loop untill the box is told to do something else.  if you could give me a map of key presses=numerical value that would be great.  The video should be interuptable.
  • 0
    Avatar
    RokuLyndon


    Actually, you don't need it but my script should read this instead:

    if chr(msg) = "r" then v.PlayFile("video1.mpg")



    Each button pressed returns an ascii value to the Brightsign. The entry "chr(msg)" looks up that value. So, you don't have to know that the number zero has a numerical value of 49, for example. If I use chr(49), it's going to give me zero.





    So, if you hit R on the keyboard, the value returns is what's in the variable "msg". So, when I do chr(msg), I get R.



    Let me know if that makes sense. If not, send me an email at <!-- e --><a href="mailto:lallydice@roku.com">lallydice@roku.com</a><!-- e -->. I have word doc with the keyboard values used when different keys are pressed. But, you don't need it.
  • 0
    Avatar
    chadmy


    Could you write a sample script where



    A=video 1 play in a loop until next command

    B=video 2 play in a loop until n....





    J=video 10 play in a loop until next command



    thank you



    Chad
  • 0
    Avatar
    RokuLyndon


    I don't have time at the moment to test this thoroughly, but it works for the first couple videos...







    kyb=CreateObject("roKeyboard")

    video=CreateObject("roVideoPlayer")

    p=CreateObject("roMessagePort")

    kyb.SetPort(p)

    current_video=""



    wait_for_keyboard:



    msg = wait(0,p)



    if type(msg) = "roKeyboardPress" then

    if chr(msg) = "a" then current_video="video1.mpg":goto play_video

    if chr(msg) = "b" then current_video="video2.mpg":goto play_video

    if chr(msg) = "c" then current_video="video3.mpg":goto play_video

    if chr(msg) = "d" then current_video="video4.mpg":goto play_video

    if chr(msg) = "e" then current_video="video5.mpg":goto play_video

    if chr(msg) = "f" then current_video="video6.mpg":goto play_video

    if chr(msg) = "g" then current_video="video7.mpg":goto play_video

    if chr(msg) = "h" then current_video="video8.mpg":goto play_video

    if chr(msg) = "i" then current_video="video9.mpg":goto play_video

    if chr(msg) = "j" then current_video="video10.mpg":goto play_video

    endif

    goto wait_for_keyboard



    play_video:

    print "Playing video: "; current_video

    video.SetLoopMode(true)

    video.PlayFile(current_video)

    goto wait_for_keyboard
  • 0
    Avatar
    RokuLyndon


    Or, something simpler...





    kyb=CreateObject("roKeyboard")

    video=CreateObject("roVideoPlayer")

    p=CreateObject("roMessagePort")

    kyb.SetPort(p)

    current_video=""

    video.SetLoopMode(true)



    wait_for_keyboard:



    msg = wait(0,p)



    if type(msg) = "roKeyboardPress" then

    if chr(msg) = "a" then video.PlayFile("video1.mpg")

    if chr(msg) = "b" then video.PlayFile("video2.mpg")

    if chr(msg) = "c" then video.PlayFile("video3.mpg")

    if chr(msg) = "d" then video.PlayFile("video4.mpg")

    if chr(msg) = "e" then video.PlayFile("video5.mpg")

    if chr(msg) = "f" then video.PlayFile("video6.mpg")

    if chr(msg) = "g" then video.PlayFile("video7.mpg")

    if chr(msg) = "h" then video.PlayFile("video8.mpg")

    if chr(msg) = "i" then video.PlayFile("video9.mpg")

    if chr(msg) = "j" then video.PlayFile("video10.mpg")

    endif

    goto wait_for_keyboard
  • 0
    Avatar
    RokuLyndon


    Or, with a little calculation.....

    -The value for A is 97 and the value for J is 106.





    kyb=CreateObject("roKeyboard")

    video=CreateObject("roVideoPlayer")

    p=CreateObject("roMessagePort")

    kyb.SetPort(p)

    video.SetLoopMode(true)



    wait_for_keyboard:

    msg = wait(0,p)



    if type(msg) = "roKeyboardPress" then

    if msg > 95 and msg < 107 then video.PlayFile("video"+right(str(msg-96),len(str(msg-96))-1)+".mpg")

    endif

    goto wait_for_keyboard
  • 0
    Avatar
    chadmy


    Thank you very much.  I will try it out as soon as I can
Please sign in to leave a comment.