Mac Through SSH to tell Quicktime Player to play a file

sidneyfox

macrumors newbie
Original poster
Oct 23, 2007
2
0
How do we tell quicktime to play a video file through SSH? I'd like to type something like:

% osascript play.scpt hello.mov

the quicktime player then will play hello.mov located in the same folder where play.scpt is.

Here is what I have, but it returns

play.scpt: execution error: No user interaction allowed. (-1713)

on run argv
process_item(item 1 of argv)
end run

-- this sub-routine processes files
on process_item(this_item)
try
tell application "QuickTime Player"
launch
activate
stop every document
close every document
open this_item
play document 1
try
repeat
if done of document 1 is true then
exit repeat
else
delay 3
end if
end repeat
close document 1
end try
end tell
return true
on error error_msg number error_num
my toggle_suppress(false)
if error_num is not -128 then
activate
display dialog error_msg buttons {"OK"} default button 1
end if
error number -128
end try
end process_item

It seems the problem is the open command. For some reason it doesn't like a file name. I'm new to Applescript. Any help is appreciated.
 

hhas

macrumors regular
Oct 15, 2007
126
0
How do we tell quicktime to play a video file through SSH? I'd like to type something like:

% osascript play.scpt hello.mov

the quicktime player then will play hello.mov located in the same folder where play.scpt is.

Here is what I have, but it returns

play.scpt: execution error: No user interaction allowed. (-1713)

Code:
on run argv
	process_item(item 1 of argv)
end run
...
It seems the problem is the open command. For some reason it doesn't like a file name.
Correct. QTP's open command requires an alias or file url object. Use:

Code:
on run argv
	process_item(POSIX file (item 1 of argv))
end run
...
You might also want to modify your error reporting code so that it re-raises the original error if the 'display dialog' command fails due to user interaction not being allowed:

Code:
	...
	if error_num is not -128 then
		activate
		try
			-- display error message (only works for host user)
			display dialog error_msg buttons {"OK"} default button 1
		on error number -1713 -- = no user interaction allowed
			-- script must've been run by non-host user, so re-throw
			-- original error message+number for their benefit
			error error_msg number error_num
		end try
	end if
	...
 
Comment

sidneyfox

macrumors newbie
Original poster
Oct 23, 2007
2
0
Thanks guys. Yeah, I got it running. Now I'm going to try to run the script in iTouch. I hope the Player on iTouch will take the command.
 
Comment
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.