FAQFAQ   SearchSearch   UsergroupsUsergroups   RegisterRegister   ProfileProfile    Log inLog in   RSS Feed

Movie PlayBack - File & Folder Browser

 
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac
View previous topic :: View next topic  
Author Message
benspink
Newbie


Joined: 20 Jun 2005
Posts: 4

PostPosted: Mon Jun 20, 2005 2:42 pm    Post subject: Movie PlayBack - File & Folder Browser Reply with quote

I'm new to Clicker...but I'm not new to Applescript.

Well, last night I sat down to write a file Browser for Clicker. I wanted to display a list of files in a folder. Done.

I wanted to display files and folders in a folder...done. If you click a folder, the list updates and you now see the contents of that folder...done.

So now we have a mini browser. The issue is that if the user clicks the "previous" button to back up a "list", I don't seem to have an event handler to catch that event.

Say my folder structure is this:
A
-1
--file a
B
-2
--file b
file c

If a user goes into A, then 1, then previous, previous, and finally clicks on "file c"...I think they are still in the "1" folder since none of my events got called when they clicked on the "Previous" button Clicker provided.

The idea here is to pick a movie that is in some subdirectory of your movie collection...then display that via VLC and initiate the VLC controller (or write my own).

I want to simulate the Tivo itnerface on my phone.

Ideas?
Back to top
View user's profile Send private message Send e-mail
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Jun 20, 2005 3:14 pm    Post subject: Reply with quote

Basically, you have two options here:

1. Let Clicker manage: Keep the lists ("up the file tree" on the widget stack) by returning true from the selection handler. This way, "back" will be handled for you.

2. Manage yourself: Drop the current list as a new one is displayed. Do this by returning false from the selection handler. Detect the "back" key by implementing the corresponding handler (I think you may have overlooked this one)

The benefit of managing the lists yourself is that you have the freedom of automatically popping to any place in the tree you want at any given point in time. If you let Clicker manage the lists by stacking them, you still have the option of using the "leave to script" command to go back to, say, the VLC script's top widget.

I hope this helps. I'm pretty sure you missed the handler for detecting when a list is dismissed.

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
benspink
Newbie


Joined: 20 Jun 2005
Posts: 4

PostPosted: Mon Jun 20, 2005 6:54 pm    Post subject: Think I found the handler... Reply with quote

Here is my script. I found what I thought was the event for the "Previous" or cancel button. I added a check for it to update my "current_path" variable. It however doesn't seem to be calling it?

Is there a way for me to refresh the current list with new values? and never let a previous button appear? I could then give a ".." item at the top to backup a dir...?

Also I had trouble finding the "SEC Helper" app to actually get its dictionary...finally found it via "ps aux" in terminal...

On another note...have you noticed things where text in applescript looks like "t/h/i/s/ /i/s/ /s/o/m/e/ /t/e/x/t"...? This seems to happen anytime you grab part of a string via the characters 1 thru 5 mthods...It was really really frustrating...Maybe a 10.4.1 bug or something...The itunes remote is affected by this too...
[code:1]
property photo_list : {}
property current_path : ""
property item_list : {}
property item_list_paths : {}
property selected_index : ""
property fullscreen_bounds : {50, -600, 800, 0} --tv output monitor is off screen

tell application "Finder" to my show_list(folder "Movies" of home as string)

on show_list(dirPath)
set current_path to dirPath
tell application "Finder"
set item_list to (name of every item of folder current_path)
set item_list_paths to (every item of folder current_path)
my select_item(1)
end tell
try
tell application "SEC Helper"
--- Show the list of movies
enter list mode title "Recordings / Movies" items item_list selected item selected_index item selected "select_item" menu dismissed "cdup"
end tell
on error
beep
end try
end show_list

on cdup()
set current_path to parent of folder current_path
tell application "Finder"
set item_list to (name of every item of folder current_path)
set item_list_paths to (every item of folder current_path)
end tell
end cdup

on select_item(itemIndex)
tell application "Finder"
if get kind of (item itemIndex in item_list_paths) = "Folder" then
my show_list((item itemIndex in item_list_paths) as string)
else
tell application "VLC" to quit
delay 1
tell application "VLC"
close every window
delay 1
set myURL to (item itemIndex in item_list_paths) as string
set myURL to my allbutfirst(myURL) --cut off the startup disk name as its not really part of the URL
set myURL to "file://" & my replace(myURL, ":", "/") --repalce ":"'s with "/"'s for URL notation
OpenURL myURL
play
fullscreen
set bounds of front window to fullscreen_bounds
delay 2
set bounds of front window to fullscreen_bounds --second atttempt since VLC seems to sometimes not listen?
end tell

tell application "SEC Helper"
--enter keypad mode text my current_picture_info() image my current_picture() image size huge
end tell
end if
end tell
return true
end select_item

on replace(theText, findStr, repStr)
set AppleScript's text item delimiters to findStr
set theList to text items of theText as list
set AppleScript's text item delimiters to repStr
return theList as text
end replace

on allbutfirst(theText)
set result_val to theText as string
set loc to 1
repeat while loc < (length of theText)
set p to character loc in theText
if p = ":" then
set result_val to ""
repeat (length of theText) - (loc) times
set result_val to result_val & character (loc + 1) of theText
set loc to loc + 1
end repeat
exit repeat
end if
set loc to loc + 1
end repeat
return result_val
end allbutfirst
[/code:1][/code]
Back to top
View user's profile Send private message Send e-mail
benspink
Newbie


Joined: 20 Jun 2005
Posts: 4

PostPosted: Mon Jun 20, 2005 7:03 pm    Post subject: I think I got it... Reply with quote

The cdup had a bug...I think it should be (so I may not have an issue at all now...I can only test when I am home and have access to my wife's phone. :(

The line:
[code:1] enter list mode title "Recordings / Movies" items item_list selected item selected_index item selected "select_item" menu dismissed "cdup"
[/code:1]
should call the cdup function now...correct?

[code:1]
on cdup()
tell application "Finder"
set current_path to parent of current_path
set item_list to (name of every item of folder current_path)
set item_list_paths to (every item of folder current_path)
end tell
end cdup
[/code:1]
Back to top
View user's profile Send private message Send e-mail
salling
Site Admin


Joined: 27 Jul 2004
Posts: 7498
Location: Stockholm, Sweden

PostPosted: Mon Jun 20, 2005 11:36 pm    Post subject: Reply with quote

At a glance, I'd say it'll be called. However, you cannot modify the list like this. Instead, push the updated list to the device. That should work. You should be able to check out the Browse by Artist script to see how to use this "pattern".

Best.
--
Jonas
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Salling Software Forums Forum Index -> Scripting Salling Clicker for Mac All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group