Background Video's

Is kJams missing a feature you need? Post it here! Note: if iTunes has it but kJams doesn't, it's a good bet kJams will have it, but that I just haven't gotten around to it yet. But go ahead and request it anyway!
DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: Background Video's

Post by DeusExMachina »

Okay, part of the problem is that Apple changed the default behaviour of Automator in response to shell script errors. So to stop the script from bailing in the newer versions of OSX, change the line that looks like this:
do shell script "rm " & slideshowFolder & "/*.*"

to look like this:

try
do shell script "rm " & slideshowFolder & "/*.*"
end try

I also suspect there will be issues now that Apple has screwed around with how fullscreen works, so I will have to test further. But so far that fixes the hang.

Karanight
Posts: 532
Joined: Sat Jan 24, 2009 2:30 am
Location: Stockport UK
Contact:

Re: Background Video's

Post by Karanight »

I have Perrin and Quicktime 7 installed on my MacBook Pro running Maverick

In the window 'Ask for Finder Items' I have in 'Prompt'
"Choose a file or folder of images to display behind Video window:" including quotes
Then in the drop down box below I have Desktop selected
And 'Type' I selected Files and Folders
I have not ticked Allow Multiple Selection
Then in Run AppleScript I've pasted your code
Then I hit Run and I get this window
1.jpg
Then I hit OK and a desktop window opens. When I select a 252kb jpg from that window I get this pop up
Attachments
the action.jpg
Posted by Len of LensKaraoke fame

Web site at
http://lenskaraoke.com

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: Background Video's

Post by DeusExMachina »

1) Post a screenshot of the entire Automator window.
You should have:
Service receives [no input] in [kJams 2 (or Pro)]
Input is [greyed out] with unchecked Allow Multiple Selection

2) You don't need quotes around the prompt.
3) did you replace the text I discussed in my last comment?
It should be:

Code: Select all

on run {input, parameters}
	
	--initialize kJams command variables
	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)
	
	-- save Quicktime Full screen state
	set fullscreenKey to "FullscreenPreferenceScreenNumber"
	set prefFile to "com.apple.quicktimeplayer"
	set keyType to "integer"
	set currentFullscreenDisplayID to (do shell script "defaults read " & prefFile & " " & fullscreenKey) as real
	--display dialog "currentFullscreenDisplayID is " & currentFullscreenDisplayID
	
	-- 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)
				try
					do shell script "rm " & slideshowFolder & "/*.*"
				end try
				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
	
	-- make video window opaque, to cover up Quicktime tomfoolery	
	tell application "System Events"
		try
			set visible of process "QuickTime Player 7" to false
		end try
	end tell
	
	tell application "kJams 2"
		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 double integer
		-- display dialog "DisplayID is " & displayID
		-- make sure default Display ID for full screen in Quicktime is the same as that used by 
		
		-- display dialog "here"
		if currentFullscreenDisplayID ≠ displayID then
			display dialog "currentFullscreenDisplayID and DisplayID are not equal"
			tell application "QuickTime Player 7" to quit
			do shell script "defaults write " & "'" & prefFile & "' '" & fullscreenKey & "' '-" & keyType & "' '" & displayID & "'"
		end if
		--display dialog "currentFullscreenDisplayID is " & currentFullscreenDisplayID & " & DisplayID is " & displayID
		
		tell application "QuickTime Player 7"
			if front document exists then close front document without saving
			--save QT state
			set playMovieBeginningWhenOpened to play movie from beginning when opened
			set play movie from beginning when opened to true
			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!)
				-- sometimes open image sequence still fails. 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
				tell application "System Events"
					try
						set visible of process "QuickTime Player 7" to false
					end try
				end tell
				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 playMovieBeginningWhenOpened
			
		end tell
		activate
		docommand kScriptCommand_TOGGLE_TRANSPARENT_VIDEO
		-- play karaoke track (if mode is not currently "playing" then play)
		if (get mode) is not 1 then docommand kScriptCommand_PLAY_PAUSE
	end tell
	return input
end run

Karanight
Posts: 532
Joined: Sat Jan 24, 2009 2:30 am
Location: Stockport UK
Contact:

Re: Background Video's

Post by Karanight »

I hadn't seen that post about replacing the text
With the new text in place I now get this pop-up
Untitled.jpg
Here's the screen shots
Untitled1.jpg
Untitled 2.jpg
Posted by Len of LensKaraoke fame

Web site at
http://lenskaraoke.com

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: Background Video's

Post by DeusExMachina »

Again, as I wrote, the action should receive "no input", NOT "text", and the selected application should be the version of kJams you are using, not "any application".
That is why you are getting the first error.
Also, what version of kJams are you using? It must match the version called in the script. If you are using Pro, it should say 'tell application "kJams Pro"' in the script. Likewise, if you are using kJams 2, everywhere it says "kJams Pro" in the script, it should say "kJams 2".

Karanight
Posts: 532
Joined: Sat Jan 24, 2009 2:30 am
Location: Stockport UK
Contact:

Re: Background Video's

Post by Karanight »

Thanks for that but I can't figure it so I won't bother, Thanks all the same
Posted by Len of LensKaraoke fame

Web site at
http://lenskaraoke.com

DeusExMachina
Posts: 1293
Joined: Sun Apr 20, 2008 9:57 am
Location: Pittsburgh, PA
Contact:

Re: Background Video's

Post by DeusExMachina »

You just have to click the "Service receives selected" pop up and set it to "none", and select kJams in the Application pop up.

dreben
Posts: 45
Joined: Sun Mar 06, 2011 5:42 pm

Re: Background Video's

Post by dreben »

Works perfect for me. Thanks for your job!
Last edited by dreben on Thu Aug 14, 2014 1:19 am, edited 1 time in total.

Karanight
Posts: 532
Joined: Sat Jan 24, 2009 2:30 am
Location: Stockport UK
Contact:

Re: Background Video's

Post by Karanight »

dreben wrote:Works perfect for me. Thanks for you job!
I have often seen post on here where kJams has been problematic for some users and there's been conversations between Dave and the user until the problem's been solved. All the time the problem's being discussed, other users, including me, (that clearly don't have the same problem and kJams works perfectly for them) might offer possible solutions. It's not very helpful to read that someone finds no problem.
I know the script works!!! I just have a problem making it work
Posted by Len of LensKaraoke fame

Web site at
http://lenskaraoke.com

dave
Site Admin
Posts: 6684
Joined: Sun Sep 18, 2005 8:02 am
Location: Seattle
Contact:

Re: Background Video's

Post by dave »

and i would jump in here and help but i don't use the script and i didn't write it, so i really don't even know about it :/

Post Reply