Code/new Video Backdrop Generator
Finally. After WAY too many false starts, and dead ends due to Apple bugs and screw ups, it is finally working. So, presenting, for your viewing pleasure, the kJams video backdrop generator! As with my other scripts lately, you can save as either a script or a service. To use, run, and select either a pic file, a video file, or a folder of pictures. If you select a sigle file, that file becomes your background. If it is a video file, it will play behind your lyrics. If you select a folder, in will play as a slide show behind your lyrics. You can change the playback speed by editing the secondsperframe value. Note: for reasons you can blame Apple for, set this value to 1/2 the desired rate.
To save as service, open automator, drag "Ask for Finder Items" to the stage. Type in "Chose a file or folder of images to display behind Video window:" into the prompt. Set Start at: to "kJams" or wherever else you think might be good, and set Type: to "Files and Folders". Leave "Allow Multiple Selection" unchecked.
Next, drag "Run Applescript" to the stage, and copy the code below into the script, overwriting all the default text. Note: if you prefer to run as a script from the script menu, you will have to edit the on run" handler to a file selection block, and you will not be able to use one script for both single files AND folders.
Save as service and you are done!
(Note: You will need to download Quicktime Player 7 (not QuickTime Player X) if you do not have it installed already.)
If you totally love this, please feel free to paypal the author.
on run {input, parameters}
--initialize kJams command variables
set kPlayModeType_STOPPED to 0
set kPlayModeType_PLAYING to 1
set kPlayModeType_PAUSED to 2
set kScriptCommand_PLAY_PAUSE to 1
set kScriptCommand_TOGGLE_TRANSPARENT_VIDEO to 24
set kScriptCommand_IS_TRANSPARENT_VIDEO to 25
set kScriptCommand_GET_VIDEO_WINDOW_DISPLAY_ID to 26
-- create list of available movie types
set movieFileTypeList to {"mov", "mp4", "m4v", "mpg", "mpeg", "avi", "dv", "flv", "gif"}
set pictureFileTypeList to {"jpg", "jpeg", "tiff", "tif", "pict", "png", "psd", "gif", "bmp", "raw"}
set secondsPerFrame to 10 -- set to half the value for seconds per frame (bad QuickTime)
-- choose file for backdrop
set fileName to first item in input
-- determine file type
tell application "Finder"
ignoring case
-- is the input a folder?
if kind of fileName is "folder" then
set isFolder to true
-- select a folder
-- make aliases of every picture file and copy to new directory
-- play image sequence*)
set slideshowFolder to ((path to music folder) as string) & "kJams:"
try
make new folder at slideshowFolder with properties {name:"imageAliases"}
end try
set slideshowFolder to (POSIX path of (slideshowFolder & "imageAliases"))
--delete entire contents of folder (POSIX file slideshowFolder as string)
do shell script "rm " & slideshowFolder & "/*.*"
set fileList to every file of folder fileName whose name extension is in pictureFileTypeList
set fileIndex to 1
repeat with theFile in fileList
-- set theFileType to the name extension of theFile (see comment below)
set theFile to POSIX path of (theFile as string)
do shell script "ln " & the quoted form of theFile & " " & the quoted form of slideshowFolder & "/image" & fileIndex & "." & "jpg" -- should be -> theFileType (if QT was not broken)
set fileIndex to fileIndex + 1
do shell script "ln " & the quoted form of theFile & " " & the quoted form of slideshowFolder & "/image" & fileIndex & "." & "jpg"
set fileIndex to fileIndex + 1
-- I do this twice because, again, QT is broken, and this forces it to show every frame.
end repeat
else
set isFolder to false
if name extension of fileName is in movieFileTypeList then
set isMovie to true
else
set isMovie to false
if name extension of fileName is not in pictureFileTypeList then error -128
end if
end if
end ignoring
end tell
tell application "kJams Pro"
-- make video window opaque, to cover up Quicktime tomfoolery
set videoTransparency to docommand kScriptCommand_IS_TRANSPARENT_VIDEO
if videoTransparency is not equal to 0 then docommand kScriptCommand_TOGGLE_TRANSPARENT_VIDEO
set displayID to (docommand kScriptCommand_GET_VIDEO_WINDOW_DISPLAY_ID) as integer
tell application "System Events"
set visible of process "QuickTime Player 7" to false
end tell
-- bring to front
activate
tell application "QuickTime Player 7"
if front document exists then close front document without saving
--save QT state
set playMovieBeginnigWhenOpened to play movie from beginning when opened
set play movie from beginning when opened to false
if isFolder then
-- The following should really be -> open image sequence (slideshowFolder as string) & "/image1." & the name extension of the first item of fileList seconds per frame secondsPerFrame (if Quicktime was not hopelessly broken!)
-- sometime open Image sequence still foil. Apple's fault. Grrr!
open image sequence (slideshowFolder as string) & "/image1.jpg" seconds per frame secondsPerFrame
set kJamsVideoBackground to the name of front document
-- make video loop
set the looping of document kJamsVideoBackground to true
else -- if single movie or picture file
open fileName
set kJamsVideoBackground to the name of the front document
-- make video loop, and kill sound
if isMovie then
set the looping of document kJamsVideoBackground to true
else
set the looping of document kJamsVideoBackground to false
end if
set the sound volume of document kJamsVideoBackground to 0
end if
--show movie full screen
present document kJamsVideoBackground display displayID
set the muted of document kJamsVideoBackground to true
set play movie from beginning when opened to playMovieBeginnigWhenOpened
end tell
activate
docommand kScriptCommand_TOGGLE_TRANSPARENT_VIDEO
-- play karaoke track (if mode is not currently "playing" then play)
if (get mode) is not kPlayModeType_PLAYING then docommand kScriptCommand_PLAY_PAUSE
end tell
return input
end run
As always, let me know back in the forum if this is useful, and if it makes you feel overwhelmingly generous, I wouldn't turn down
a little PayPal contribution to my motivation fund :)
