Forum closed
This forum was closed and turned into an archive effective April 21, 2018. It is no longer possible to create new topics or reply to existing topics.

Thanks everyone for all the great questions and contributions over the years.

Please use the Contact form to get in touch.

Remote Buddy Forum

Overview 

AuthorThread
User

13.01.2012 00:08:30
Re: Applescript, IP control, and integration with Thinkflood's Redeye and other A/V devices

This posting is older than 6 months and can contain outdated information.
 
Thanks for asking.

1. Is there any way to remotely launch a specific RBE menu (like iTunes>Playlist) via XMLhttpRequests.... I figured out how to launch the items on the manus (via AJAX remote) but not the menus themselves. I am trying to make the iTunes playlists more accessible by adding an item on the main menu the jumps into a specific playlist and I can't figure it out... I made applescript app that asks for a playlist tracks and creates an RBE menu out of them works but when I do it with a playlist internet radio stations it gets all screwed up and does not list all of them.. but it work fine on the RBE 'Browse Music so it would be great if I could just launch the RBE's

iTunes>Playlist Menu

 
Unfortunately, I can't think of a way to do this.

 
Hi Felix,

Success! I was able to create an applescript that can queries an itunes playlist, spit the tracks back into a RB menu, and then play the selected track (or radio station). Its kind of a hack but it does the job ;)

--works inside remote buddy only 
--Must have iTunes playlist called "Internet Radio"

tell application "iTunes" 
set radio_list to name of (tracks of playlist "Internet Radio") 
set radio_list to radio_list & radio_list 
end tell

set radio_names_sorted to simple_sort(the radio_list)

tell application "Remote Buddy Express" 
showmenu with items radio_names_sorted menu name "example" 
end tell

on menureturn(hiddenID, menuname) 
tell application "iTunes" 
play track hiddenID of playlist "Internet Radio" 
end tell 
end menureturn

on simple_sort(my_list) 
set the index_list to {} 
set the sorted_list to {} 
repeat (the number of items in my_list) times 
set the low_item to "" 
repeat with i from 1 to (number of items in my_list) 
if i is not in the index_list then 
set this_item to item i of my_list as text 
if the low_item is "" then 
set the low_item to this_item 
set the low_item_index to i 
else if this_item comes before the low_item then 
set the low_item to this_item 
set the low_item_index to i 
end if 
end if 
end repeat 
set the end of sorted_list to the low_item 
set the end of the index_list to the low_item_index 
end repeat 
return the sorted_list 
end simple_sort

2. What approach would you suggest for creating behaviors to control hardware like a DVD player. I am currently creating a behavior and associating it with the RBE app which is causing problems. Can I associate a RBE activity with an applescript app? Maybe that is a cleaner approach?

 
It depends on what you want to do. If all you want is to create one Behaviour per device you want to control, the correct approach is to not associate the Behaviour with any application, but instead create an extra action and assign it as action to execute when the Behaviour gets activated. That extra action should contain an AppleScript actor with this code - which will make your Behaviour remain active until you explicitely choose another Behaviour:

tell application "Remote Buddy" to behaviourcore accessor "setSticky" with stickyValue

Once that action is created, you can reuse it in all your Behaviours.

 
Great... thanks for the tip. What application (if any) should I associate the constructed DVD behavior with? I think I remember needing to associate it with RB in order to get it to work when I was testing. Maybe I should create an applescript app that runs while i'm controlling the DVD player... any thoughts?

3. What approach would you suggest to create behavior profile for control browser based apps like Pandora? Do I just associate the behavior with Safari and give it a greater priority number?

 
I'd suggest the same approach as 2), but add a few extra lines of code to the activation AppleScript that opens the web service's URL in Safari - or brings any Safari window into focus that already has that URL loaded. I can't offer you AppleScript code for that, though.

 
Good idea... I'll look into this and post any results.

4. Is there any way to control the sort order of RBE's output for the files in my Movies folder... I'm pretty sure you can use applescript to query the finder but I'm trying to stay in RBE native menu system?

 
There's currently no way to change that sort order.

 
I was thinking that I might be able to query the Finder to spit back a list of the files in the Movie folder in newest to oldest and then do what I did above in the iTunes script... i'll look into it.

Thanks for your help!

Christian

 

 
Best regards, 
Felix Schwarz 
Thread-display::