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


Click here to return to the 'View movie trailers and music videos in QT Player' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
View movie trailers and music videos in QT Player
Authored by: macsolve on Jun 30, '04 05:16:12PM
I've always missed to be able to control click an embedded movie and choose "Play movie with QuickTime Player", like the Real Player plugin lets me do.
Here's an AppleScript to pass an embedded movie automagically to QT Player. If there are more than one embedded movie on a page it asks which one to view.
I've put this on an iKey hotkey. Very neat.

Note: This script does not see embedded movies inside of frames. Open frame in new tab first.

(* script to pass embedded movie URLs from Safari to QT Player 
   Written by Johan Sölve 2004-04-02 *)
tell application "Safari"
  set BaseUrl to URL of document 1
  if (source of document 1) as string is "" then
    set objecturl to BaseUrl
  else
    set embeds to (do JavaScript "n= '';for (var i=0; i<document.getElementsByTagName('embed').length;i++) 
      {n = n + (document.getElementsByTagName('embed').item(i).src) + \"\\r\"; if(document.getElementsByTagName('embed').item(i).href) 
      {n=n+(document.getElementsByTagName('embed').item(i).href) + \"\\r\"}}" in document 1)
    if (count paragraphs of embeds) > 1 then
      set embeds to items 1 thru -2 of (paragraphs of embeds)
    else
      set embeds to {}
    end if
    
    set objecturl to ""
    if (count embeds) is 1 then
      set objecturl to item 1 of embeds
    else if (count embeds) > 0 then
      set embedsShow to {}
      repeat with thisEmbed in embeds
        tell me to set embedsShow to embedsShow & first item of split(last item of (split(thisEmbed, "/")), "?")
      end repeat
      set choice to (choose from list embedsShow with prompt "Play in QuickTime Player:" default items {last item of embedsShow})
      if choice is not false then
        set counter to 1
        repeat with thisEmbed in embedsShow
          if (thisEmbed as string) is (item 1 of choice) then
            set objecturl to (item counter of embeds)
            exit repeat
          end if
          set counter to counter + 1
        end repeat
      end if
    end if
  end if
end tell

if objecturl is not "" then
  if objecturl does not contain "://" then
    if objecturl begins with "/" then
      set BaseUrl to join(items 1 thru 3 of split(BaseUrl, "/"), "/")
    else
      set BaseUrl to join(items 1 thru -2 of split(BaseUrl, "/"), "/") & "/"
    end if
    set objecturl to BaseUrl & objecturl
  end if
  ignoring application responses
    tell application "QuickTime Player"
      activate
      getURL objecturl
    end tell
  end ignoring
  
end if


on split(theString, splitAt)
  set olddelim to AppleScript's text item delimiters
  set AppleScript's text item delimiters to splitAt
  set theString to every text item of theString
  set AppleScript's text item delimiters to olddelim
  return theString
end split

on join(theString, joinWith)
  set olddelim to AppleScript's text item delimiters
  set AppleScript's text item delimiters to joinWith
  set theString to (theString as string)
  set AppleScript's text item delimiters to olddelim
  return theString
end join


[ Reply to This | # ]
A fine script!
Authored by: Alidoro on Jun 30, '04 09:20:24PM

macsolve, thanks for the script, it works like a charm!



[ Reply to This | # ]