Thursday, March 30, 2017

#1 2017-03-15 12:13:50 pm

artphotodude
Member
Registered: 2012-10-15
Posts: 42

QT Theatré X v2.0 Update! Directory-Based media player.

Created this originally for OS9 due to its lack of decent multi-format media players and this will the 2nd and final OSX version (Universal PPC/Indel | OSX 10.4-10.8). 

The premise is simple, rather than making playlists or dropping/selecting a group of files to play, QT Theatré X is aimed at a directory and it finds and dynamically creates a playlist of all playable files, then runs them one after another in alphabetical or random mode.

Version 2 improves the stability greatly and adds a few nice new features - that are especially nice for the vintage Mac crowd.

1. Now holds volume-levels and window positions when changing from one file to the next.

2. Offers Audio (Normal or Random), Video (Normal or Random) and All (Normal or Random) modes.

3. Video-only modes also have a pretty smooth fullscreen-play option.

4. Supports lots of additional file-types with Perian and Flip4Mac installed (but if they are not installed, simply skips-over those formats).

- Audio -
.MP3, .AIFF, .WAV, .OGG, .AC3 and .WMA

- Video -
.MP4, .MOV, .AVI, .3GPP/2, .FLV, .WEBM, .MKV, .OGV, MPEG/2 (Mpgs are hit and miss due to only partial-compatibility in older versions of QT) and .WMV


DL Link:
https://www.dropbox.com/s/d7vms3one36kj … 0.zip?dl=0

*Tested on OSX 10.4.11. HD-videos pretty much need a top DP G4 or a G5 or Intel, but otherwise should run on most any G4 or better.  Might well work in post-Mavericks versions of OSX, but the menus will look weird because of the newer (wider) dialog format.


Applescript:


----
-- "QT Theatré X" (Version 2.0) for QuickTime Player 7 (Mac OS X 10.4). Written by Adam Albrec (game_creator@hotmail.com)
----
-- 03/15/2017
----


-- Prevents timeout during operation.
with timeout of 86400 seconds
   
   
   -- Checks if Perian is installed to enable playback of OGG, AC3, FLV, WEBM, OGV and MPG/MPG2 files.
   set perianInstalled to false
   set perianTest to (do shell script "if test -e /Library/PreferencePanes/Perian.prefPane/; then echo 1; else echo 0; fi") as text
   if perianTest is "1" then
       set perianInstalled to true
   else
       set perianTest to (do shell script "if test -e ~/Library/PreferencePanes/Perian.prefPane/; then echo 1; else echo 0; fi") as text
       if perianTest is "1" then
           set perianInstalled to true
       end if
   end if
   
   -- Checks if Flip4Mac is installed to enable playback of WMA/WMV files.
   set flip4macInstalled to false
   set flip4macTest to (do shell script "if test -e /Library/QuickTime/Flip4Mac\\ WMV\\ Advanced.component/; then echo 1; else echo 0; fi") as text
   if flip4macTest is "1" then
       set flip4macInstalled to true
   else
       set flip4macTest to (do shell script "if test -e ~/Library/QuickTime/Flip4Mac\\ WMV\\ Advanced.component/; then echo 1; else echo 0; fi") as text
       if flip4macTest is "1" then
           set flip4macInstalled to true
       end if
   end if
   
   
   ----
   -- Selection.
   ----
   
   -- Prompts user to select directory of Audio/Video files. Filters out non-playable files, then for Audio, Video or playback of both in normal or random modes.
   tell me
       activate
       set mediaPath to (choose folder) as alias
   end tell
   set playbackMode to ""
   tell me
       activate
       set playbackMode to (choose from list {"Play Audio Files - Normal", "Play Audio Files - Random", "Play Video Files - Normal", "Play Video Files - Random", "Play Everything! - Normal", "Play Everything! - Random"} with prompt " Select Playback Mode:" OK button name "OK" cancel button name "Cancel" default items "Play Audio Files - Random" without multiple selections allowed) as text
   end tell
   if playbackMode is "false" then
       error number -128
   end if
   
   -- Sets to windowed-playback by default.
   set windowMode to ""
   
   
   ----
   -- Sets File-Sort according to selected playback mode.
   ----
   
   -- Audio files
   if playbackMode contains "Audio" then
       set windowMode to " Windowed"
       tell application "System Events" to set mediaFileList to ((every file of mediaPath) whose visible is true) as list
       set filteredmediaFileList to {}
       set x to "1"
       set n to the number of items of mediaFileList
       repeat n times
           ignoring case and diacriticals
               if name of item x of mediaFileList contains ".mp3" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".aiff" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".wav" then
                   set filteredmediaFileList's end to item x of mediaFileList
               end if
               if perianInstalled is true then
                   if name of item x of mediaFileList contains ".ogg" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".ac3" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   end if
               end if
               if flip4macInstalled is true then
                   if name of item x of mediaFileList contains ".wma" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   end if
               end if
           end ignoring
           set x to x + "1"
       end repeat
       set mediaFileList to filteredmediaFileList
       
       -- Exits if no playable files ar found.
       set mediaFileList to filteredmediaFileList
       if the (count of mediaFileList) is 0 then
           tell me
               activate
               beep
               display dialog " Sorry - No Playable Audio Found!" with icon 2 buttons "OK" default button "OK"
               error number -128
           end tell
       end if
       
       -- Video files. Also prompts user for Fullscreen or Windowed playback (defaults to Fullscreen in 5-seconds).
   else if playbackMode contains "Video" then
       tell me
           activate
           display dialog " Choose Video Playback-Style...

*Defaulting to Fullscreen in
5-Seconds"
with icon alias ((path to me) & "Contents:Resources:applet.icns" as string) buttons {" Windowed", "Fullscreen"} default button "Fullscreen" giving up after 5
       end tell
       set windowMode to button returned of the result
       if windowMode is not " Windowed" then
           set windowMode to "Fullscreen"
       end if
       tell application "System Events" to set mediaFileList to ((every file of mediaPath) whose visible is true) as list
       set filteredmediaFileList to {}
       set x to "1"
       set n to the number of items of mediaFileList
       repeat n times
           ignoring case and diacriticals
               if name of item x of mediaFileList contains ".mp4" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".mov" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".avi" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".3gpp" then
                   set filteredmediaFileList's end to item x of mediaFileList
               end if
               if perianInstalled is true then
                   if name of item x of mediaFileList contains ".flv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".webm" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".mkv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".ogv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".mpeg" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".mpg" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   end if
               end if
               if flip4macInstalled is true then
                   if name of item x of mediaFileList contains ".wmv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   end if
               end if
           end ignoring
           set x to x + "1"
       end repeat
       set mediaFileList to filteredmediaFileList
       
       -- Exits if no playable files ar found.
       set mediaFileList to filteredmediaFileList
       if the (count of mediaFileList) is 0 then
           tell me
               activate
               beep
               display dialog "Sorry - No Playable Videos Found!" with icon 2 buttons "OK" default button "OK"
               error number -128
           end tell
       end if
       
       -- Play all playable files.
   else if playbackMode contains "Everything!" then
       set windowMode to " Windowed"
       tell application "System Events" to set mediaFileList to ((every file of mediaPath) whose visible is true) as list
       set filteredmediaFileList to {}
       set x to "1"
       set n to the number of items of mediaFileList
       repeat n times
           ignoring case and diacriticals
               if name of item x of mediaFileList contains ".mp4" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".mp3" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".mov" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".aiff" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".avi" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".wav" then
                   set filteredmediaFileList's end to item x of mediaFileList
               else if name of item x of mediaFileList contains ".3gpp" then
                   set filteredmediaFileList's end to item x of mediaFileList
               end if
               if perianInstalled is true then
                   if name of item x of mediaFileList contains ".flv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".webm" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".mkv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".ogg" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".ogv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".mpeg" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".mpg" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".ac3" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   end if
               end if
               if flip4macInstalled is true then
                   if name of item x of mediaFileList contains ".wmv" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   else if name of item x of mediaFileList contains ".wma" then
                       set filteredmediaFileList's end to item x of mediaFileList
                   end if
               end if
           end ignoring
           set x to x + "1"
       end repeat
       set mediaFileList to filteredmediaFileList
       
       -- Exits if no playable files ar found.
       set mediaFileList to filteredmediaFileList
       if the (count of mediaFileList) is 0 then
           tell me
               activate
               beep
               display dialog " Sorry - No Playable Media Found!" with icon 2 buttons "OK" default button "OK"
               error number -128
           end tell
       end if
   end if
   
   -- Reshuffles list of files if a random playback mode was chosen.
   if playbackMode contains "Random" then
       script s
           property l : mediaFileList
       end script
       set i to count of l of s
       repeat while i ≥ 2
           set j to random number from 1 to i
           set {item i of l of s, item j of l of s} to {item j of l of s, item i of l of s}
           set i to i - 1
       end repeat
       l of s
   end if
   
   
   ----
   -- Playback
   ----
   
   -- Variables Ini.
   set mediaFileListCount to the number of items of mediaFileList
   set mediaFileListRun to 1
   set qtAudioWindowScaleANDPosition to ""
   set qtVideoWindowScaleANDPosition to ""
   set qtCurrentVolume to "256"
   
   -- Set window-focus to QuickTime for fullscreen playback or Finder for windowed
   if windowMode is " Windowed" then
       tell application "Finder" to activate
   else
       tell application "QuickTime Player" to activate
   end if
   
   -- Loads and plays each file in sequence by alphabetical (normal) or random modes as selected earlier.
   repeat mediaFileListCount times
       set currentMediaFile to ((the path of item mediaFileListRun of mediaFileList) as alias)
       try
           tell application "QuickTime Player"
               open currentMediaFile
               set theFile to the front document
               set theFIleName to the name of theFile
           end tell
           
           -- Delays play until the file is loaded into QuickTime.
           set fileDuration to ""
           repeat
               try
                   tell application "QuickTime Player"
                       set fileDuration to the duration of theFile
                   end tell
               end try
               if fileDuration is not "" then
                   exit repeat
               end if
           end repeat
           
           -- Sets subsequent files to the same audio volume as the previous one.
           tell application "QuickTime Player"
               set the sound volume of theFile to qtCurrentVolume
               
               -- Windowed.
               
               -- Gets current file-type and sets window-size/position to match the previous one of the same type (Audio or Video).
               if windowMode is " Windowed" then
                   set fileExtention to ""
                   set audioExtensions to {"ac3", "aiff", "mp3", "ogg", "wav", "wma"}
                   tell application "Finder" to set fileExtention to the name extension of currentMediaFile
                   if audioExtensions contains fileExtention then
                       set fileType to "Audio"
                   else
                       set fileType to "Video"
                   end if
                   if fileType is "Audio" then
                       try
                           tell window theFIleName to set the bounds to qtAudioWindowScaleANDPosition
                       end try
                   else
                       try
                           tell window theFIleName to set the bounds to qtVideoWindowScaleANDPosition
                       end try
                   end if
               else
                   
                   -- Fullscreen (available only for video-only playback).
                   
                   -- Enters fullscreen.
                   delay 0.33
                   present theFile scale screen
                   
                   -- Starts the file playing if autoplay is not set in QuickTime Options.
                   tell theFile to play
               end if
               
               
               -- Starts the file playing if autoplay is not set in QuickTime Options.
               tell theFile to play
           end tell
           
           -- Window Controller.
           repeat
               
               -- QuickTime 'User Settings' checker (Primary).
               tell application "QuickTime Player"
                   
                   -- Gets current audio volume to use in subsequent files/s.
                   set qtCurrentVolume to the sound volume of theFile
                   if windowMode is " Windowed" then
                       
                       -- Gets current window size and position to use in subsequent file/s.
                       
                       -- Audio
                       if fileType is "Audio" then
                           set qtAudioWindowScaleANDPosition to the bounds of window theFIleName
                           
                           -- Video
                       else
                           set qtVideoWindowScaleANDPosition to the bounds of window theFIleName
                       end if
                   end if
               end tell
               
               -- Exits script if QuickTime is quit (Primary).
               tell application "System Events"
                   set qtRunning to count of (every process whose name is "QuickTime Player")
                   if qtRunning is not greater than or equal to 1 then
                       error number -128
                   end if
               end tell
               
               -- Closes QuickTime window once finished playing.
               tell application "QuickTime Player"
                   set fileDuration to the duration of theFile
                   set currentTime to the current time of theFile
               end tell
               if currentTime = fileDuration then
                   close theFile
                   exit repeat
               end if
               delay 1
               
               -- QuickTime 'User Settings' checker (Secondary).
               tell application "QuickTime Player"
                   
                   -- Gets current audio volume to use in subsequent files/s.
                   set qtCurrentVolume to the sound volume of theFile
                   if windowMode is " Windowed" then
                       
                       -- Gets current window size and position to use in subsequent file/s.
                       
                       -- Audio
                       if fileType is "Audio" then
                           set qtAudioWindowScaleANDPosition to the bounds of window theFIleName
                           
                           -- Video
                       else
                           set qtVideoWindowScaleANDPosition to the bounds of window theFIleName
                       end if
                   end if
               end tell
           end repeat
       end try
       
       -- Exits script if QuickTime is quit (Secondary).
       tell application "System Events"
           set qtRunning to count of (every process whose name is "QuickTime Player")
           if qtRunning is not greater than or equal to 1 then
               error number -128
           end if
       end tell
       
       -- 2-second playback delay between files and selects next item in file-list.
       delay 2
       set mediaFileListRun to mediaFileListRun + 1
   end repeat
   
   
   
   -- End of script.
end timeout

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.079 seconds, 9 queries executed ]

RSS (new topics) RSS (active topics)