Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to play a DVD stored in a folder System
To save wear and tear on my Superdrive I have copied two two DVDs that my daughter watches constantly into my HD using DVDbackup. In order to make them easy to play, I have built my first AppleScript, which I attached to the folder containing the video files using Folder Actions. When the folder is opened, the script opens DVD Player, selects the right media and presses Play. I have updated the folder icons with pictures of the cartoon characters that feature in the movie.
on opening folder this_folder
  tell application "Finder"
    activate
    close window of this_folder
    set this_name to the name of this_folder
    display dialog "Would you like to play the movie ? " & 
     this_name buttons {"Yes", "No"} default button 1 giving up after 5
    set the user_choice to the button returned of the result
  end tell
  if the user_choice is not "No" then
    try
      tell application "DVD Player"
        activate
        open VIDEO_TS this_folder
        set viewer full screen to true
        play dvd
      end tell
    on error number errNumber
      display dialog errNumber buttons {"OK"} 
       default button "OK" with icon 2
    end try
  end if
end opening folder
I'm sure someone can tell me how to hide, rather than close, the folder window and un-hide it if the user answers 'no' to the dialog. I find the AppleScript documentation a litte obtuse!
    •    
  • Currently 2.33 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[14,875 views]  

A script to play a DVD stored in a folder | 17 comments | Create New Account
Click here to return to the 'A script to play a DVD stored in a folder' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to play a DVD stored in a folder
Authored by: vdubya on Jul 12, '04 10:16:01AM

I've got a better idea. Buy a cheap DVD player and let the kids use that instead of an expensive computer.

http://www.amazon.com/exec/obidos/tg/detail/-/B00008N6X3/qid=1089641626/br=1-3/ref=br_lf_etk_ce_av__3//103-9958394-6587065?v=glance&s=electronics&n=172516

I'd rather toss a peanutbutter-laden el cheaper player into the trash than my Mac! :)



[ Reply to This | # ]
Another way to do the same thing ...
Authored by: mike508 on Jul 12, '04 11:40:23AM

I use Mac the Ripper to get the files on my hard drive, delete all of the "extras" and create a playlist in VLC (Videolan Client) to play an entire movie. HTH

Mike



[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: designr on Jul 12, '04 08:36:59PM

tell application "Finder"
activate
set collapsed of window 1 to true
end tell



[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: taxi on Jul 12, '04 08:40:49PM

I bought an Xbox, and got it modded so I can use XboxMediaCenter, which now means I can play all of my AAC music, view all of my photos and watch movies, all from my TV.

Of course, in this case, one is better of converting the DVD (movie only, usually, although I sometimes grab the extra director's soundtrack) to some smaller movie format.

I've found HandBrake to be a bit unstable at times, and actually use my PC to convert & store movies. (They take up a bit more room, and my iMac is used for more important stuff).



[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: myrkr on Jul 13, '04 02:47:16PM

Only one suggestion, it might be easier to understand the dialog boxes with "play" or "cancel" instead of "yes" and "no"

display dialog "Would you like to play the movie ? " &
---> this_name buttons {"Yes", "No"} default button 1 giving up after 5

Especially for kids and such.



[ Reply to This | # ]
HandBrake!
Authored by: Lectrick on Jul 13, '04 05:17:59PM

Step 1) Load HandBrake
Step 2) Rip the kids' flick into a 700mb mp4 movie with a 96khz AAC audio track, autocropped. For extra quality, do a 2-pass rip.
Step 3) Wait a few hours.
Step 4) Repeat for other movies.
Step 5) Have kids open movie(s) in Quicktime, or applescript QuickTime.
Step 6) When kids get bored of movie, archive to a regular CD-ROM, so your DVD disc stays pristine.

I'm pretty sure the AppleScript docs for QuickTime Player are pretty complete if you look in the player's library with Script Editor.

---
In /dev/null, no one can hear you scream



[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: tc_nyc on Jul 14, '04 09:34:50AM
First, I'm disappointed that this forum is devoving into a 'me too' hangout for people to post completely off-topic messages like designr did. I'm sure there are dozens of ways to watch DVDs on your Mac, and that some people don't want their kids to watch DVDs on their computer. But that's not what the original post was about... it was about how to get DVD Player to open a VIDEO_TS folder automatically.

I would like to suggest that all posters take a moment before writing a reply to ask yourself "is what I'm writing helpful and relevent?".

Anyway, I like this little script but would love to run it as a standalone script instead of a folder action. I can't seem to figure out a way to work around the reliance on the this_folder class.

Does anyone know how to grab the name of the parent folder in a non-folder action script?

[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: osxpounder on Jul 14, '04 12:16:49PM

Surely you didn't mean to refer to designr, who, according to my reading of the page, answered a specific question asked by the hint's author, and did it succinctly. Designr was generous enough to offer help, and I'm sure I'm not the only one who appreciated it.

Perhaps you refer to the poster who suggested one should purchase a DVD player. I don't agree that it's off topic to suggest this, considering the hint's author devised this hint to handle "two DVDs that my daughter watches constantly".

Folks, don't let complaints discourage you; please keep posting whatever you think would be helpful, and know that many of us are grateful for your time and your thoughts.

---
--
osxpounder



[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: Accura on Jul 14, '04 08:48:15PM

Well said osxpounder

jameso

---
"The time has come," the walrus said. "To talk of many things..."



[ Reply to This | # ]
Me Too!!!!
Authored by: tc_nyc on Jul 15, '04 04:50:28PM
I stand corrected. In fact, designr was not guilty of posting off topic.

But vdubya, taxi, myrkr, mike508 and now Accura all have the off-topic virus.

But now we have three more messages in this forum that don't speak to my question.

I expect it when I read Slashdot, not Mac OS X Hints.

[ Reply to This | # ]
A script to play a DVD stored in a folder
Authored by: periche on Jul 15, '04 06:47:43PM
Save as Application not showing the startup screen

set this_folder to choose folder with prompt "Select VIDEO_TS folder to Play"
open this_folder


on open this_folder
   try
      tell application "DVD Player"
         activate
         open VIDEO_TS this_folder
         set viewer full screen to true
         play dvd
      end tell
   on error errMessage number errNumber
      display dialog errNumber & return & errMessage buttons {"OK"} 
         default button "OK" with icon 2
   end try
end open


[ Reply to This | # ]
Very close....
Authored by: tc_nyc on Jul 16, '04 05:33:02PM

This script almost does what I'm looking for, except that it presents a dialog box. I would prefer to find a way for the script to fill the this_folder variable automatically based on it's location.

Thanks for the effort!



[ Reply to This | # ]
Very close....
Authored by: periche on Jul 16, '04 10:25:10PM
Try this:

-- Initialize variables
set this_folder to ""
set folderContentTypes to {}

-- First check to see if the folder containing this application contains movies
set myPath to path to me as alias

tell application "Finder"
	set parentFolder to container of (myPath)
	try
		-- If the folder containing this application contains any files
		if (count of (every file of parentFolder)) > 0 then
			-- Lets get a list with the file type and the name extension of every file in the folder containing this application
			set folderContentTypes to (file type of (every file of parentFolder) & name extension of (every file of parentFolder))
		end if
	end try
	-- If the file Type or the extension of any file is VOB will use the parent folder to play
	if "VOB" is in folderContentTypes then
		set this_folder to parentFolder
	else
		-- Otherwise check to see if the parent folder contains a folder named VIDEO_TS then use it to play (This is cool if you make disk images of dvds, then include this applet withing the top level of the image
		if "VIDEO_TS" is in (name of (every folder of myPath)) then
			set this_folder to (folder "VIDEO_TS" of folder myPath) as alias
		end if
	end if
end tell

if this_folder is "" then
	-- Could not find VOB files nor VIDEO_TS folder in parent folder, therefore ask to choose a folder
	set this_folder to choose folder with prompt "Select VIDEO_TS folder to Play"
end if

open this_folder

on open this_folder
	try
		tell application "DVD Player"
			activate
			open VIDEO_TS this_folder
			set viewer full screen to true
			play dvd
		end tell
	on error errMessage number errNumber
		display dialog errNumber & return & errMessage buttons {"OK"} 
			default button "OK" with icon 2
	end try
end open


[ Reply to This | # ]
Very close... (but needed some work)
Authored by: lowrider on Sep 27, '07 04:02:01PM

Thank you very much, Terry, tc_nyc, and periche, for the initial idea and implementation, refined specs, and updated solution, respectively. I happen to have very similar needs.

Alas, periche's script doesn't work (at least for me), so I tracked down 2 small but relevant bugs and expanded the comments a bit:


-- Initialize variables:
set this_folder to ""
set folderContentTypes to {}

-- First check to see if the folder containing this application (= parent folder) contains movies:
set myPath to path to me as alias -- Caution: This only works as expected for the final stand-alone script applet.
-- For testing in a script editor, temporarily provide an absolute path like
-- set myPath to "Macintosh HD:Users:Shared:Movies:DVDs:MY_FAVOURITE_DVD:Play DVD.app" as alias
-- wherein 'Play DVD.app' is the name of this script applet. Otherwise, you'll just get the path to the script editor application,
-- like for example "Macintosh HD:Applications:AppleScript:Script Editor.app:", which eventually leads to being asked to
-- "Select VIDEO_TS folder to play" even if there is a perfectly valid VIDEO_TS folder right next to the script applet...

tell application "Finder"
	set parentFolder to container of (myPath)
	try
		-- Check to see if the parent folder contains any files:
		if (count of (every file of parentFolder)) > 0 then
			-- Lets get a list with the file types and the name extension of every file in the parent folder:
			set folderContentTypes to (file type of (every file of parentFolder) & name extension of (every file of parentFolder))
		end if
	end try
	-- If the file type or the extension of any file is VOB, we will use the parent folder to play:
	if "VOB" is in folderContentTypes then
		set this_folder to parentFolder
	else
		-- Otherwise check to see if the parent folder contains a folder named VIDEO_TS, then use it to play:
		-- (This is cool if you make disk images of DVDs, you can include this applet within the top level of the image.)
		-- Here I found the 1st bug: it was 'myPath' instead of 'parentFolder'
		if "VIDEO_TS" is in (name of (every folder of parentFolder)) then
			-- And that was the 2nd bug: it read 'folder myPath' instead of just 'parentFolder'
			set this_folder to (folder "VIDEO_TS" of parentFolder) as alias -- 
		end if
	end if
end tell

if this_folder is "" then
	-- Could find neither VOB files nor VIDEO_TS folder in parent folder, therefore ask the user to choose a VIDEO_TS folder:
	set this_folder to choose folder with prompt "Select VIDEO_TS folder to play"
end if

open this_folder

on open this_folder
	try
		tell application "DVD Player"
			activate
			open VIDEO_TS this_folder
			set viewer full screen to true
			play dvd
		end tell
	on error errMessage number errNumber
		display dialog errNumber & return & errMessage buttons {"OK"} 
			default button "OK" with icon 2
	end try
end open

As noted by periche: Save as an Application not showing the startup screen.

It then works nicely for me, especially when I present my family with a friendlier starting point by

  1. creating an alias to the AppleScript applet,
  2. giving it the movie's proper name,
  3. decorating it with a suitable custom icon and
  4. finally putting it in a convenient place like /Users/Shared/Movies.

Enjoy or enhance!



[ Reply to This | # ]
Very close... (but needed some work)
Authored by: jamster321 on Mar 16, '10 04:53:46PM

Hi all,

I've been trying to find something to achieve what the script above does, thanks a lot for providing this here!

However I found that when the code was loading the mac OS DVD player, and making it full screen, it didn't always display widescreen films correctly. When I loaded Alien it was stretched and was cut off the bottom of the screen.

This is corrected by telling DVD player to initiate Full Screen mode AFTER the DVD has started playing.

This means just changing the last bit of code relating to DVD player - see below


tell application "DVD Player"
activate
open VIDEO_TS this_folder
play dvd
set viewer full screen to true
end tell

Thanks for providing this in the first place!

Jamie



[ Reply to This | # ]
Very close... (but needed some work)
Authored by: NameUndecided on Mar 29, '10 08:29:43PM

Hi all --
I am going to come out and say that apple script baffles me at the moment. I found this thread through a Google search in trying to find out if I could open Mac folders in the DVD player. It turns out that I can (yay!) -- but I have no experience with apple script beyond my trying to do this one thing off and on over the past couple of days.
I have searched for apple script tutorials, and I am able to enable the pre-written scripts such as "add - new item alert" and the "close" and "convert" scripts and that -- but much of anything else seems to be some degrees off from my current level of understanding.
I have tried copying and pasting and tweaking the above given scripts -- but my folder action enabled folders with VIDEO_TS folders within them still open up as normal.
Would someone possibly be able to write a short step by step tutorial for how to enable these scripts for someone with my... erm, level of understanding, and who seemingly doesn't have the need for apple scripts beyond this one thing?
Thank you so much if anyone is able to help. Please forgive my ignorance -- I'd just really like to have this feature for a growing list of folders I'm storing. Dragging and dropping to the DVD Player icon is... boring and cumbersome.
Thanks.



[ Reply to This | # ]
Very close... (but needed some work)
Authored by: NameUndecided on Mar 30, '10 07:18:36PM

...nevermind that previous comment. I just stumbled upon a different approach while using a new DVD ripping program.

Simply add the extension ".dvdmedia" to a folder that contains the VIDEO_TS file and then hide the extension and change the icon if you'd like. Suddenly it's a package that opens in DVD player. Why... on earth isn't everyone doing simply this?

...Because you're all psychopaths.



[ Reply to This | # ]