0

Remote Control Using Soundbridge IR remote HELP!!!



I am currently onsite with time running out fast. I am using a HD1010 with Iguanaworks IR unit and a roku soundbridge remote. I cannot for the life of me get it to play this audio file in a loop with the play button and then have volume control while its playing either. Im using pause to stop it. Nothing is working, ive tried to my best knowledge with no prevail. Please help. THanks a ton in advance. Here is my code. p = CreateObject("roMessagePort") remote = CreateObject("roIRRemote") video = CreateObject("roVideoPlayer") mode=CreateObject("roVideoMode") remote.SetPort(p) video.SetPort(p) REM REM Set Video mode REM ok = mode.SetMode("1280x720x60p") video.SetAudioOutput(0) 'sets volume to analog, change to 2 for HDMI REM REM Constants media_end=8 'value returned when a video stops playing play=9 '9 is returned when you press the play button stop_video=12 '12 is returned when you press the pause button volup=16 voldown=17 'current_volume=100 wait_for_play: msg = wait(0, p) if type(msg) = "roIRRemotePress" then if debug print "Button pressed: ";msg.GetInt() if msg.GetInt() = play then if debug print "Play pressed!" video.PlayFile("audio.mp3") 'playing video video.SetLoopMode(0) else if msg.GetInt() = stop_video then video.StopClear() else if msg.GetInt() = volup and current_volume < 100 then current_volume = current_volume +10 video.SetVolume(current_volume) else if msg.GetInt() = voldown and current_volume > 0 then current_volume = current_volume - 10 video.SetVolume(current_volume) endif goto wait_for_play

4 comments

  • 0
    Avatar
    RokuLyndon


    I'm not somewhere where I can test this, but your problems were:

    1. You were using the video object to play an mp3. So, I changed to an audio player object.

    2. You were setting loop mode to zero. You need to set to 1 to have the audio loop indefinitely.


    p = CreateObject("roMessagePort")
    remote = CreateObject("roIRRemote")
    audio = CreateObject("roAudioPlayer")
    mode=CreateObject("roVideoMode")
    remote.SetPort(p)
    audio.SetPort(p)

    REM
    REM Set Video mode
    REM
    ok = mode.SetMode("1280x720x60p")
    audio.SetAudioOutput(0)   'sets volume to analog, change to 2 for HDMI

    REM
    REM Constants
    media_end=8       'value returned when a video stops playing
    play=9             '9 is returned when you press the play button
    stop_video=12       '12 is returned when you press the pause button
    volup=16
    voldown=17
    'current_volume=100

    wait_for_play:
    msg = wait(0, p)

    if type(msg) = "roIRRemotePress" then
      if debug print "Button pressed: ";msg.GetInt()


      if msg.GetInt() = play then
         if debug print "Play pressed!"
         audio.SetLoopMode(1)  
         audio.PlayFile("audio.mp3") 'playing audio

      else if msg.GetInt() = stop_video then
         audio.Stop()
     
      else if msg.GetInt() = volup and current_volume < 100 then
         current_volume = current_volume +10
         audio.SetVolume(current_volume)
     
      else if msg.GetInt() = voldown and current_volume > 0 then
         current_volume = current_volume - 10
         audio.SetVolume(current_volume)
      endif
    goto wait_for_play

  • 0
    Avatar
    RokuLyndon


    Added one more change. I had missed the video.setaudiooutput setting. I changed that to audio.setaudiooutput.
  • 0
    Avatar
    Kurt Durjan


    I figured out a solution using bright author it works well for the ir commands. Tried using what I had plus your changes and it was still throwing an error and rebooting. Thanks lyndon and thanks brightauthor! <!-- s:) --><img src="{SMILIES_PATH}/icon_smile.gif" alt=":)" title="Smile" /><!-- s:) --> Im glad we made it work somehow was all that mattered.
  • 0
    Avatar
    RokuLyndon


    Great news. BrightAuthor definitely makes it easier. But, I was finally able to test this so here's the corrected script should anyone else need it.

    debug = true
    p = CreateObject("roMessagePort")
    remote = CreateObject("roIRRemote")
    audio = CreateObject("roAudioPlayer")
    mode=CreateObject("roVideoMode")
    remote.SetPort(p)
    audio.SetPort(p)

    REM
    REM Set Video mode
    REM
    ok = mode.SetMode("1280x720x60p")
    audio.SetAudioOutput(0)   'sets volume to analog, change to 2 for HDMI

    REM
    REM Constants
    media_end=8       'value returned when a video stops playing
    play=9             '9 is returned when you press the play button
    stop_video=12       '12 is returned when you press the pause button
    volup=16
    voldown=17
    current_volume=100

    wait_for_play:
    msg = wait(0, p)

    if type(msg) = "roIRRemotePress" then
      if debug print "Button pressed: ";msg.GetInt()


      if msg.GetInt() = play then
         if debug print "Play pressed!"
         audio.SetLoopMode(1)  
         audio.PlayFile("audio.mp3") 'playing audio

      else if msg.GetInt() = stop_video then
         audio.Stop()
     
      else if msg.GetInt() = volup and current_volume < 100 then
         current_volume = current_volume +10
         audio.SetVolume(current_volume)
     
      else if msg.GetInt() = voldown and current_volume > 0 then
         current_volume = current_volume - 10
         audio.SetVolume(current_volume)
      endif
     endif
     
    goto wait_for_play

Please sign in to leave a comment.