New Wireless Remote Controller for OtsAV

Started by milky, July 13, 2014, 09:35:38 AM

Previous topic - Next topic

milky

My son has a small laptop he uses in his car running OtsAVDJ. Until now, it was not easy to pause a track or skip to a new track whilst driving, but, today we built a new controller for his smartphone.
Here's how it works:
1) It uses a program from vectir.com that lets you configure buttons on the phone, and link those to applications on the PC.
2) You create an ad hoc wireless link between the PC and the phone. Bluetooth and IR options are also available.
3) I wrote and compiled some AHK scripts for PLAY, PAUSE, STOP, PREVIOUS and NEXT which pass the appropriate wParam to Ots
4) My son designed the phone screen buttons, and we embedded the link to the AHK exe for each function.
5) Now, with Ots running on the laptop (which is in a harness under his seat), a simple tap of the appropriate button on the phone will make the function fire, without fiddling about with mouse or keyboard command.

I've been messing about with an iPod for a long time, and, even with controls on the steering wheel, it's reliability is not good, so I will be copying what my son has done as soon as I get a new licence for the little ten inch micro Toshiba I bought recently.
OtsDJ           PDI = PAAA-BHVP,  PBQN-3658
S & L               PDI = PAAA-BK27 x 2
Studio             PDI = PAAA-BL38

Jumpin' Jeff

Good stuff to know Milky! Thanks for sharing!
I've been working on a TCP/IP application that does similar. It's in c#! I've yet to make the link to Ots, but it's all I have to do at the moment. finding the time to get back to it is the problem. Should only take minutes when I do.
Jeff Main

You can please some of the people some of the time, all of the people some of the time, some of the people all of the time, but you can never please all of the people all of the time. 
Abraham Lincoln
 
OtsAV license holder for life.
PDI: OtsAV TV Broadcaster PARC-KHY7

milky

I think the PC side "server" program was US$5, and the phone app was free. Not a big cost.

BTW, per-to-peer network capability has been removed from Win 8, but there is a way via the command prompt, thanks to wiki-how.

Two lines of code, which can be set into a batch file:-
netsh wlan set hostednetwork mode=allow ssid="CarAP" key="<password here>"
netsh wlan start hostednetwork


This is the code for "PAUSE.exe"
;
; AutoHotkey Version: 1.x
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2

; Following line just emits a short "beep" to indicate the keypress has worked. Can be commented out if you want silent operation

SoundPlay, C:\OtsLabs\KeyPress.Mp3

WinActivate, OtsAV
WinWaitActive, OtsAV
SendMessage,0x111,40121,0,,OtsAV


The code for the other functions are identical, except the change to the wParam value in the "sendMessage line.
PLAY = 40120
STOP = 40122
PREVIOUS = 40123
NEXT = 40124
OtsDJ           PDI = PAAA-BHVP,  PBQN-3658
S & L               PDI = PAAA-BK27 x 2
Studio             PDI = PAAA-BL38

Jumpin' Jeff

My method works more on the concept of the Ots RAC. That should still work even on win8.
I will be looking into your method though also.
Jeff Main

You can please some of the people some of the time, all of the people some of the time, some of the people all of the time, but you can never please all of the people all of the time. 
Abraham Lincoln
 
OtsAV license holder for life.
PDI: OtsAV TV Broadcaster PARC-KHY7

milky

Below is version 2 of the remote screen. It now includes a volume slider and two playlist launchers (one for the oldies and a bit more kid-friendly, and the other - anything goes). I've now developed a program to audibly announce the currently playing track and artist, but yet to add the button. This uses the RAC to retrieve "Now Playing" info, and then uses text-to-voice to announce it, pausing Ots whilst speaking.

For you code boffins - here's the script.


;
; Script Function:
; Retrieve "Now Playing" from RAC, Pause OtsAV, announce Artist/Track, continue playing
;

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.
SetTitleMatchMode, 2

IfWinExist,History
{
WinClose,History,,1,
}

IfWinExist,- [
{
WinClose,- [,,1,
}

SoundPlay, C:\OtsLabs\KeyPress.Mp3

WinActivate, OtsAV
WinWaitActive, OtsAV

FileDelete, racnowplaying.txt

    RAC_Address=%A_IPAddress1%:80

    URLDownloadToFile, http://%RAC_Address%/x/query.cgi?q=status, racnowplaying.txt
    FileReadLine, NowPlayingStatus, racnowplaying.txt, 3

If SubStr(NowPlayingStatus,8,7)="Playing"
{
    FileReadLine, NowPlayingArtist, racnowplaying.txt, 4
    FileReadLine, NowPlayingTitle, racnowplaying.txt, 5
    StringTrimLeft, TrimmedNowPlayingArtist, NowPlayingArtist, 7
    StringTrimLeft, TrimmedNowPlayingTitle, NowPlayingTitle, 6
    LastTrack := TrimmedNowPlayingArtist . ". " . TrimmedNowPlayingTitle

SendMessage,0x111,40121,0,,OtsAV

ComObjCreate("SAPI.SpVoice").Speak(LastTrack)

Sleep 400
SendMessage,0x111,40121,0,,OtsAV
}


OtsDJ           PDI = PAAA-BHVP,  PBQN-3658
S & L               PDI = PAAA-BK27 x 2
Studio             PDI = PAAA-BL38

milky

I've fallen out of love with the wifi version. It certainly works, and with extended range, but it kept dropping out on my phone and I had to disable/enable wifi on the phone to take control back. I've now got the blue tooth version working perfectly, and it doesn't lose the plot. Interestingly, RAC works, but doesn't have an IP. Weird.
OtsDJ           PDI = PAAA-BHVP,  PBQN-3658
S & L               PDI = PAAA-BK27 x 2
Studio             PDI = PAAA-BL38

Jumpin' Jeff

Jeff Main

You can please some of the people some of the time, all of the people some of the time, some of the people all of the time, but you can never please all of the people all of the time. 
Abraham Lincoln
 
OtsAV license holder for life.
PDI: OtsAV TV Broadcaster PARC-KHY7