• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: How to manipulate MP3 file in QuickTime Player
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to manipulate MP3 file in QuickTime Player


  • Subject: Re: How to manipulate MP3 file in QuickTime Player
  • From: Brennan Young <email@hidden>
  • Date: Mon, 20 Jun 2005 14:33:42 +0200

Neil Faiman <email@hidden> wrtoe

I have QuickTime Pro. I want to open a .mp3 file in QuickTime Player so that I can export it as an AAC file. I'm sure that this code used to work (in QT6? Panther? I don't know exactly when):

*set* theMp3File *to* theFile *as* *Unicode text*
*set* theAACFile *to* (*text* 1 *through* -4 *of* theMp3File) & "m4a"
*tell* *application* "QuickTime Player"
*set* theTrackDocument *to* *open* *file* theMp3File
*export* theTrackDocument *to* *file* theAACFile *as* *MPEG4* *using* *default settings*


Now, when I run it, QuickTime Player opens the file as expected, but then I get an error message that "The variable theTrackDocument is not defined."

Any suggestions?

Yes, this is a new bug in QuickTime 7. Hooray!

It broke a bunch of my scripts too. I used to do a lot of

tell (open (choose file))

...perfectly well-formed code for QT6, so it took me a while to find out what was wrong.

In a nutshell, the 'open' command does not return a reference to the opened document the way it used to. In fact it returns nothing at all.

I *think* this is a general cocoa scripting bug (you can test with TextEdit to find out) and as such it may be fixed in Tiger. I am on the wrong OS to test right now (Windows XP!).

To make matters worse I think that 'open' fails silently - i.e. you can't trap a failed 'open' with a try... block. This is also a bug. Arguably a different one.

Workaround is to assume that 'movie 1' is the movie you just opened

open file theMp3File
set theTrackDocument to movie 1

This will work most of the time. It will fail if 'open' fails, for example if the file is corrupted.

This will cause unpredicatable results if there is another movie open because 'movie 1' will remain the frontmost movie from before, if one exists.

Also someone (or something, some... script) may open yet another movie in that little slice of time between you opening yours and you referring to 'movie 1', in which case movie 1 might be a different movie to what you expect, but we can assume that this is very unlikely. Even so, scripts can open a lot of files very quickly, so just keep it in mind.

To guard against these problems, count movies before and after issuing 'open', and/or check that 'file of movie 1' (or whatever it's called) is the same as theMp3File after opening.

Good luck!

Brennan

--
"Now let's all synchronize our watches and look forward to a better tomorrow." - Fred Lane
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: How to manipulate MP3 file in QuickTime Player
      • From: Neil Faiman <email@hidden>
  • Prev by Date: Re: Renaming recursively
  • Next by Date: Open .term Files in 10.3
  • Previous by thread: How to manipulate MP3 file in QuickTime Player
  • Next by thread: Re: How to manipulate MP3 file in QuickTime Player
  • Index(es):
    • Date
    • Thread