Trying to create a video viewer applescript

I’ve tried this many times but had to luck. I used to have a start, but I deleted it.

What I’m trying to to is this.

Display dialog “Welcome to desktop video viewer!” buttons {“Add video”, “Watch videos”}

So when I press the watch video button, I want it to display a list of all the .avi files on my desktop. Then I want to be able to select it and watch the video in quicktime.

When I press the add video button, I want to be able to find an .avi in a browser INSIDE a dialog box. When I find it I want to be able to select it, click ADD, and it adds it to the desktop (which also adds it to the list when I click watch video.) I know you could easily do this with finder and drag it to the desktop, but I want it like this just for show.


something like this

set {button returned:buttonReturned} to display dialog "Welcome to desktop video viewer!" buttons {"Add video", "Watch videos"}
if buttonReturned is "Add video" then
	set chosenFiles to choose file with prompt "select avi file(s)" of type "public.avi" with multiple selections allowed
	tell application "Finder" to move chosenFiles to desktop
	tell application "Finder" to set theFiles to name of files of desktop whose name extension is "avi"
	set fileToWatch to choose from list theFiles with prompt "choose a file"
	if fileToWatch is false then return
	set filePath to ((path to desktop as text) & (item 1 of fileToWatch))
	tell application "QuickTime Player" to open filePath
end if

Thanks thats just what I needed