Basic EyeTV Control from PiaF

jpe

Member
Joined
Nov 14, 2007
Messages
149
Reaction score
0
Here is something i pilfered and prodded during the Haiti relief show. It works, but it is dog slow on my system. Takes 20 seconds to respond. I am prolly doing something wrong. I pretty much photoshopped the whole thing. You will need a Cepstral voice to use this properly. You will also have to make a sound file for the menu.

Noobs like me should be able to get a grip of whats going on looking at the code.
One of you Guru's will hack it up some more and make it so channel numbers can be entered and "record for 30 minutes" commands can be implemented.


Create control file
We need to make a file that translates into the apple events for the mac.
Create a text file and copy the stuff below into it.

------

Code:
#!/bin/sh
#
#
####################################
# EyeTV Control v0.1
# mangled by [email protected]
# Jan 22, 2010
#
# based on
# iTunes Command Line Control v1.1
# written by David Schlosnagle
# created 2001.11.08
# see: http://www.macosxhints.com/article.php?story=20011108211802830
# modifications by Wayne k. Walrath - http://www.acmetech.com/ [2004.06.01]
#
####################################

showHelp () {
    echo "-----------------------------";
    echo "EyeTV Command Line Interface";
    echo "-----------------------------";
    echo "Usage: `basename $0` <option>";
    echo;
    echo "Options:";
    echo " play     = Start playing EyeTV.";
    echo " pause    = Pause EyeTV.";
    echo " playpause    = Toggle Play/Pause EyeTV.";
    echo " next     = Go to the next channel.";
    echo " prev     = Go to the previous channel.";
    echo " mute     = Mute EyeTV' volume.";
    echo " unmute   = Unmute EyeTV' volume.";
    echo " volup   = Increase EyeTV' volume by 10%";
    echo " voldown = Increase EyeTV' volume by 10%";
    echo " stop     = Stop EyeTV.";
    echo " fullscreen     = Enter Full Screen.";
    echo " exitfullscreen     = Exit Full Screen.";
 
}

if [ $# = 0 ]; then
    showHelp;
fi

while [ $# -gt 0 ]; do
    arg=$1;
    case $arg in

        "play"    ) echo "Playing EyeTV.";
            osascript -e 'tell application "EyeTV" to play';
            break ;;

        "pause"    ) echo "Pausing EyeTV.";
            osascript -e 'tell application "EyeTV" to pause';
            break ;;

     "playpause"    ) echo "Toggle EyeTV Play/Pause.";
            osascript -e 'tell application "EyeTV" to playpause';
            break ;;

        "next"    ) echo "Going to next EyeTV channel." ;
            osascript -e 'tell application "EyeTV" to channel_up';
            break ;;

        "prev"    ) echo "Going to previous EyeTV channel.";
            osascript -e 'tell application "EyeTV" to channel_down';
            break ;;

        "mute"    ) echo "Muting EyeTV volume level.";
            osascript -e 'tell application "EyeTV" to mute';
            break ;;

           "stop"    ) echo "Stopping EyeTV.";
            osascript -e 'tell application "EyeTV" to stop';
            break ;;
            
        "fullscreen"    ) echo "EyeTV Entering Full Screen.";
            osascript -e 'tell application "EyeTV" to enter full screen';
            break ;;

        "exitfullscreen" ) echo "EyeTV Exiting Full Screen";
            osascript -e 'tell application "EyeTV" to exit full screen';
            break ;;

    "volup"    ) echo "Raising EyeTV Volume.";
            osascript -e 'tell application "EyeTV" to volume_up';
            break ;;
            
        "voldown"    ) echo "Lowering EyeTV Volume.";
            osascript -e 'tell application "EyeTV" to volume_down';
            break ;;

    "startrecord"    ) echo "Start Recording EyeTV.";
            osascript -e 'tell application "EyeTV" to start recording';
            break ;;
            
        "stoprecord"    ) echo "Stop Recording EyeTV.";
            osascript -e 'tell application "EyeTV" to stop recording';
            break ;;


            esac
done
Save it to your EyeTV Mac desktop as 'eyetv'

Copy File to Proper Location
Open up the app 'Terminal' on the Mac
Switch to root -
Code:
sudo su
Enter your password (user password)
Enter the following commands to copy the file to the right place.

Code:
cd Desktop
cp eyetv /bin/eyetv
chmod +x /bin/eyetv
You should now be able to control EyeTV from the Terminal. Test it by entering the command to play/pause

Code:
eyetv playpause

Set Up SSH

if you don't know the ip address for your mac enter the following command in Terminal

Code:
ifconfig
look for "en0" then "inet" that should be your ip address. (or "en1). Write that down.

Or go into System Preferences/Network and look it up on the interface your using.

Now log into your asterisk box command line as root.
Now switch to the asterisk user.

Code:
su asterisk
Now enter

Code:
ssh-keygen -t rsa
Hit return three times. Use default location, no passphrase
Copy the public key file to the Mac with EyeTV. Replace 'username' with your mac username and '192.168.1.100' with the mac's ip address (what you wrote down earlier)

Code:
scp /var/lib/asterisk/.ssh/id_rsa.pub [COLOR=DarkRed][B][I]username[/I][/B][/COLOR]@[COLOR=DarkRed][B][I]192.168.1.100[/I][/B][/COLOR]:/Users/[COLOR=DarkRed][B][I]username[/I][/B][/COLOR]/.ssh/authorized_keys
Setup Dialplan
Now log into the Admin web page and go to Config Edit.
Open up 'extensions_custom.conf' and scroll to the bottom.
Paste below in

---

Code:
[eyetv-control]
exten => s,1,Answer
exten => s,n,NoOp(EyeTV Remote Control)
exten => s,n,set(user=[COLOR=DarkRed][I][B]username[/B][/I][/COLOR])            ; changeme
exten => s,n,set(eyetvhost=[B][I]192.168.1.100[/I][/B])                ; changeme
exten => s,n,Wait(1)
exten => s,n,background(texttospeech/EyeTV-Menu); prompt sound file location
exten => s,n,background(beep)

; 1 Enter Full Screen
exten => 1,1,Swift(Enter full screen.)
exten => 1,n,system(ssh ${user}@${eyetvhost} /bin/eyetv fullscreen)
exten => 1,n,goto(99,1)

; 2 Volume Up
exten => 2,1,Swift(Volume Up)
exten => 2,n,system(ssh ${user}@${eyetvhost} /bin/eyetv volup)
exten => 2,n,goto(99,1)

; 3 Exit Full Screen
exten => 3,1,Swift(Exit Full Screen)
exten => 3,n,system(ssh ${user}@${eyetvhost} /bin/eyetv exitfullscreen)
exten => 3,n,goto(99,1)

; 4 Channel Down
exten => 4,1,Swift(Channel Down)
exten => 4,n,system(ssh ${user}@${eyetvhost} /bin/eyetv prev)
exten => 4,n,goto(99,1)

; 5 Play/Pause
exten => 5,1,swift("Play Pause")
exten => 5,n,system(ssh ${user}@${eyetvhost} /bin/eyetv playpause)
exten => 5,n,goto(99,1)

; 6 Channel Up
exten => 6,1,Swift(Channel Up)
exten => 6,n,system(ssh ${user}@${eyetvhost} /bin/eyetv next)
exten => 6,n,goto(99,1)

; 7
exten => 7,1,Swift(Not Used)
;exten => 7,n,system(ssh ${user}@${eyetvhost} )
exten => 7,n,goto(99,1)

; 8 Volume Down
exten => 8,1,Swift(Volume Down)
exten => 8,n,system(ssh ${user}@${eyetvhost} /bin/eyetv voldown)
exten => 8,n,goto(99,1)

; 9
exten => 9,1,Swift(Not Used)
;exten => 9,n,system(ssh ${user}@${eyetvhost} )
exten => 9,n,goto(99,1)

; 0 Mute
exten => 0,Swift(Volume Mute)
exten => 0,n,system(ssh ${user}@${eyetvhost} /bin/eyetv mute)
exten => 0,n,goto(99,1)

; *
exten => 1,1,Swift(Start Recording)
exten => *,n,system(ssh ${user}@${eyetvhost} /bin/eyetv startrecord)
exten => *,n,goto(99,1)

; #
exten => 1,1,Swift(Stop Recording)
exten => #,n,system(ssh ${user}@${eyetvhost} /bin/eyetv stoprecord'
exten => #,n,goto(99,1)

exten => 99,1,NoOp(${SYSTEMSTATUS})
exten => 99,n,GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?99,6)
exten => 99,n,Swift(Successfully Executed)
exten => 99,n,goto(s,5)
exten => 99,n,background(im-sorry)
exten => 99,n,background(an-error-has-occured)
exten => 99,n,wait(1)
exten => 99,n,background(goodbye)
exten => 99,n,Hangup
exten => t,1,goto(s,1)
exten => h,1,Hangup
---

Make sure to change user=Username and eyetvhost=192.168.1.100 (marked changeme) above.

Save and hit 'Re-Read Configs'

Setup Extension
Now Navigate to the "Custom Destinatioins' Module under the Tools section.
Add a Custom Destination -
Code:
Custom Destination: eyetv-control,s,1
Description: EyeTV Control (or whatever you want)
Now navigate to "Misc Application" under Setup.
add Misc Application - Description ETV Remote (or whatever you want)
Code:
Feature Code: 393 (eye (or whatever you want))
Destination: Custom Destination: EyeTV Control (or whatever you named it)
After that you should be good to go.

Dial 393 (or whatever you used) and try it out.
Controls
The controls are
1 - Full Screen
2 - Volume Up
3 - Exit Full Screen
4 - Channel Down
5 - Play/Pause
6 - Channel Up
7 - Not Used
8 - Volume Down
9 - Not Used
0 - Mute
* - Start Recording
# - Stop Recording

I did a hack job from the following sources:
http://nerdvittles.com/index.php?p=159
http://support.elgato.com/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=3298
http://www.acmetech.com/extras/tips.html

hope I didn' t miss anything

enjoy
jpe
 
Rewrote dialplan

I rewrote the dialplan to make it more interesting.

Code:
[eyetv-control]
exten => s,1,Answer
exten => s,n,NoOp(EyeTV Remote Control)
exten => s,n,set(user=mantic)            ; changeme
exten => s,n,set(eyetvhost=192.168.1.33)                ; changeme
exten => s,n,Read(commandiz,texttospeech/EyeTV-Menu|1|3|10)

exten => s,n,GotoIf($["${commandiz}" = "1"]?fullscreen)
exten => s,n,GotoIf($["${commandiz}" = "2"]?volup)
exten => s,n,GotoIf($["${commandiz}" = "3"]?exitfs)
exten => s,n,GotoIf($["${commandiz}" = "4"]?chandn)
exten => s,n,GotoIf($["${commandiz}" = "5"]?playpause)
exten => s,n,GotoIf($["${commandiz}" = "6"]?chanup)
exten => s,n,GotoIf($["${commandiz}" = "7"]?startrec)
exten => s,n,GotoIf($["${commandiz}" = "8"]?voldn)
exten => s,n,GotoIf($["${commandiz}" = "9"]?stoprec)
exten => s,n,GotoIf($["${commandiz}" = "0"]?mute)
exten => s,n,GotoIf($["${commandiz}" = "*"]?hmenu)
exten => s,n,GotoIf($["${commandiz}" = "#"]?notused)
exten => s,n,HangUp

exten => s,n(fullscreen),Noop(1 - EyeTV Full Screen)
exten => s,n(fullscreen),Set(rcommand=full<D-c>screen)
exten => s,n(fullscreen),NoOp
exten => s,n(fullscreen),Swift(Entering Full Screen)
exten => s,n(fullscreen),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand})
exten => s,n(fullscreen),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(fullscreen),Swift(Full Screen Activated)
exten => s,n(fullscreen),Goto(s,5)
exten => s,n(fullscreen),hangup

exten => s,n(volup),Noop(2 - EyeTV Volume Up)
exten => s,n(volup),Set(rcommand=volup)
exten => s,n(volup),NoOp
exten => s,n(volup),Swift(Turn Volume Up)
exten => s,n(volup),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(volup),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(volup),Swift(Volume turned up One Notch.)
exten => s,n(volup),Goto(s,5)
exten => s,n(volup),hangup

exten => s,n(exitfs),Noop(3 - EyeTV Exit Full Screen)
exten => s,n(exitfs),Set(rcommand=exitfullscreen)
exten => s,n(exitfs),NoOp
exten => s,n(exitfs),Swift(Exit Full Screen)
exten => s,n(exitfs),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(exitfs),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(exitfs),Swift(Full Screen Deactivated)
exten => s,n(exitfs),Goto(s,5)
exten => s,n(exitfs),hangup

exten => s,n(chandn),Noop(4 - EyeTV Channel Down)
exten => s,n(chandn),Set(rcommand=chandn)
exten => s,n(chandn),NoOp
exten => s,n(chandn),Swift(Channel Down)
exten => s,n(chandn),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(chandn),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(chandn),Swift(Channel Changed)
exten => s,n(chandn),Goto(s,5)
exten => s,n(chandn),hangup

exten => s,n(playpause),Noop(5 - EyeTV Volume Up)
exten => s,n(playpause),Set(rcommand=playpause)
exten => s,n(playpause),NoOp
exten => s,n(playpause),Swift(Pump Up the Volume)
exten => s,n(playpause),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(playpause),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(playpause),Swift(Volume Raised One Notch)
exten => s,n(playpause),Goto(s,5)
exten => s,n(playpause),hangup

exten => s,n(chanup),Noop(6 - EyeTV Channel Up)
exten => s,n(chanup),Set(rcommand=chanup)
exten => s,n(chanup),NoOp
exten => s,n(chanup),Swift(Channel Up)
exten => s,n(chanup),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(chanup),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(chanup),Swift(Channel Changed)
exten => s,n(chanup),Goto(s,5)
exten => s,n(chanup),hangup

exten => s,n(startrec),Noop(7 - EyeTV Start Recording)
exten => s,n(startrec),Set(rcommand=startrec)
exten => s,n(startrec),NoOp
exten => s,n(startrec),Swift(Start Recording)
exten => s,n(startrec),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(startrec),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(startrec),Swift(Recording Started)
exten => s,n(startrec),Goto(s,5)
exten => s,n(startrec),hangup

exten => s,n(voldn),Noop(8 -EyeTV Volume Down)
exten => s,n(voldn),Set(rcommand=voldown)
exten => s,n(voldn),NoOp
exten => s,n(voldn),Swift(Turn Down Volume)
exten => s,n(voldn),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(voldn),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(voldn),Swift(Volume Lowered One Notch)
exten => s,n(voldn),Goto(s,5)
exten => s,n(voldn),hangup

exten => s,n(stoprec),Noop(9 - EyeTV Stop Recording)
exten => s,n(stoprec),Set(rcommand=stoprec)
exten => s,n(stoprec),NoOp
exten => s,n(stoprec),Swift(Stop Recording
exten => s,n(stoprec),system(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(stoprec),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(stoprec),Swift(Recording Stopped)
exten => s,n(stoprec),Goto(s,5)
exten => s,n(stoprec),hangup

exten => s,n(mute),Noop(0 - EyeTV Mute)
exten => s,n(mute),Set(rcommand=mute)
exten => s,n(mute),NoOp
exten => s,n(mute),Swift(Mute Volume
exten => s,n(mute),trysystem(ssh ${user}@${eyetvhost} /bin/eyetv ${rcommand}) 
exten => s,n(mute),GotoIf($["${SYSTEMSTATUS}" = "APPERROR"]?aperror)
exten => s,n(mute),Swift(Volume Muted)
exten => s,n(mute),Goto(s,5)
exten => s,n(mute),Hangup

exten => s,n(hmenu),Noop(* - EyeTV Control Menu)
exten => s,n(hmenu),Swift(Press the appropriate button to do something.
exten => s,n(hmenu),Swift("Got it, Homer?"
exten => s,n(hmenu),Goto(s,5)
exten => s,n(hmenu),hangup

exten => s,n(notused),Noop(# - EyeTV Not Used)
exten => s,n(notused),Swift(No Hash Here)
exten => s,n(notused),Goto(s,5)
exten => s,n(notused),hangup

exten => s,n(aperror),NoOp(Error)
exten => s,n(aperror),Swift(The system failed. Please try again)
exten => s,n(aperror),NoOp
exten => s,n(aperror),Goto(s,5)
exten => s,n(aperror),hangup

exten => h,1,hanup
exten => t,1,goto(s,5)
 

Members online

Forum statistics

Threads
26,686
Messages
174,406
Members
20,257
Latest member
Dempan
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Back
Top