5 Replies Latest reply: Jan 18, 2013 1:16 PM by Pierre L.
A.P.M. Wülfinghoff Level 1 Level 1 (5 points)

I use for some years the following AppleScript to play audiofiles:

[within Filemaker Pro]

 

set url_path to cell "bestandspad" of current record

set tekst to ""

 

 

display dialog (get url_path)

 

 

tell application "QuickTime Player"

display dialog  "een"

            try

            display dialog  "twee"

            open URL url_path

            display dialog  "drie"

                   if  not exists document 1 then

                                 set tekst to "next"

                                display dialog  "vier"     

                   else

                             play document 1                       

                   end if

            end try

end tell

 

 

set the clipboard to tekst

 

Forget the dialogs; after the statement "open URL url_path" the QTP statement " The process cannot be completed" (roughly translated) appears.

 

This occurs all of a sudden after the update from OS 10.7.5 to 10.8.2, I am quite sure.

Any idesas?


iMac, Mac OS X (10.7.5), FileMaker Pro 11
  • 1. Re: Mountain Lion and Applescript
    Pierre L. Level 4 Level 4 (3,860 points)

    The following version of your script seems to work pretty well with the chosen URL, at least when run from the AppleScript Editor window:

     

     

    set url_path to "http://listen.radionomy.com/aclassicfm-web.m3u"

    set tekst to ""

    display dialog (get url_path)

    display dialog "een"

    display dialog "twee"

    tell application "QuickTime Player" to open URL url_path

    display dialog "drie"

    tell application "QuickTime Player" to set doc1Exists to (exists document 1)

    if not doc1Exists then

        set tekst to "next"

        display dialog "vier"

    end if

    set the clipboard to tekst


     

    Message was edited by: Pierre L.

  • 2. Re: Mountain Lion and Applescript
    A.P.M. Wülfinghoff Level 1 Level 1 (5 points)

    I ran your program on the editor and it runs fine.

    I changed it a bit, included your trick to make QTP invisible, and I added my open URL statement.

    I understand it doesn't work on your computer, but when played in the editor, it shows exactly what goes wrong.

     

    tell application "QuickTime Player" to activate

     

     

    --set url_path to "http://listen.radionomy.com/aclassicfm-web.m3u"

    set url_path to "file://localhost/Users/apmwulfinghoff/Documents/POPMUZIEK/ALBUMS/Music/Beatles /Rubber%20Soul/04%20Nowhere%20man.mp3"

    set tekst to ""

    display dialog (get url_path)

     

    tell application "QuickTime Player" to open URL url_path

     

    delay 0.1

    tell application "System Events"

              set visible of process "QuickTime Player" to false

              repeat until visible of process "QuickTime Player" is false

              end repeat

    end tell

     

    tell application "QuickTime Player" to set doc1Exists to (exists document 1)

    if not doc1Exists then

              set tekst to "next"

    else

      --play document 1????

    end if

     

    set the clipboard to tekst

     

    On opening URL a QTP message is displayed "The process cannot be completed" and it appears, that document 1 doesn't exist.

    I have run this line for over two years and it always worked. The path is taken from the xml file of iTunes.

    Possibly Mountain Lion handles the path differently, as the problem came with my updating to 10.8.2

    I would appreciate if you could have another look at it.

  • 3. Re: Mountain Lion and Applescript
    Pierre L. Level 4 Level 4 (3,860 points)

    After choosing a song in my iTunes library, I added “file://localhost” to the beginning of its POSIX path (/Users/pierre/Music/iTunes/iTunes Media/Music/Compilations/Gold - Greatest Hits/11 Chiquitita.m4a) and tried your script with this URL. As expected, it didn't work.

     

    Then I tried the same URL in a sligthly modified version of your initial script, just replacing "QuickTime Player” with “QuickTime Player 7” and “open URL” with “getURL”, and guess what… it worked!

     

     

    set url_path to "file://localhost/Users/pierre/Music/iTunes/iTunes Media/Music/Compilations/Gold - Greatest Hits/11 Chiquitita.m4a"

    set tekst to ""

     

    display dialog (get url_path)

     

    tell application "QuickTime Player 7"

        display dialog "een"

        try

            display dialog "twee"

            getURL url_path

            display dialog "drie"

            if not (exists document 1) then

                set tekst to "next"

                display dialog "vier"

            else

                play document 1

            end if

        end try

    end tell

     

    set the clipboard to tekst

     

     

    See article HT3678: Installing QuickTime Player 7.

  • 4. Re: Mountain Lion and Applescript
    A.P.M. Wülfinghoff Level 1 Level 1 (5 points)

    Oh Lord, it is a miracle, it is working indeed.

    I always thought, that programming was a rational activity, but I am beginning to doubt it.

    Thanks a lot.

    Still have to find out how to play the song, but that can't be too difficult.

  • 5. Re: Mountain Lion and Applescript
    Pierre L. Level 4 Level 4 (3,860 points)

    My pleasure.