QTMovieVIew

Hi,

I’m struggling with getting a movie playing in a QTMovieView in my ApplescriptObjC application.

I’ve tried various methods based on bits and pieces i’ve read on these forums and elsewhere.

below seems like the most likely method to work, but it doesn’t


script qtPlayerAppDelegate
	
	property parent : class "NSObject"
	property movieView : missing value
	property QTMovie : missing value
	
	on applicationWillFinishLaunching_(aNotification)
		-- Insert code here to initialize your application before any files are opened 
		
		set theMoviePath to POSIX path of (choose file with prompt "Choose a movie:" without invisibles)
		# set movieLoaded to (call method "loadMovie:withPath:" of class "qtPlayer" with parameters {my movieView, theMoviePath})
		set showMovie to QTMovie's initWithFile_(theMoviePath)
		movieView's setMovie_(showMovie)
		movieView's play_()
		
	end applicationWillFinishLaunching_
	
	on applicationShouldTerminate_(sender)
		-- Insert code here to do any housekeeping before your application quits 
		return current application's NSTerminateNow
	end applicationShouldTerminate_
	
end script

movieView is liked to a QTMovieView in IB
QTMovie is linked to a QTMovie object in IB

I can choose a movie and seems to get loaded into the QTmovieView but when i hit play nothing happens.

I’m pretty new to this, so I think it’s quite likely i’m making a fairly simple mistake, but there doesn’t seem to be much in the way of docs for ApplescriptObjC that I can find and I’m stumped.

Any help very much appreciated.

Cheers
Louis

Make sure you add the QTKit.framework to the project. Then try this:

	property movieView : missing value -- connected to movie view in IB
	
	on applicationWillFinishLaunching_(aNotification)
		set theMoviePath to POSIX path of (choose file with prompt "Choose a movie:" without invisibles)
		tell current application's QTMovie to set {theMovie, theErr} to movieWithFile_error_(theMoviePath, reference)
		tell movieView
			setMovie_(theMovie)
			play_(me)
		end tell
	end applicationWillFinishLaunching_

Shane,

Thanks very much, that works a treat. Wish this stuff was documented a bit better!

Just that bit of code has opened up a load of new possibilities.
Wish I had to time to read all of this forum.

Cheers
Louis

I know this was posted 2 years ago, but it appears to be the only documentation i can find regarding QT player and applescriptobjc.

I added this to my script and it freezes the application when activated. The sound plays and I can double click the QTmovieView to start and stop it, but nothing visually updates. Even the “load” movie button you press to initiate the code is blue (pressed down). Any ideas?

I narrowed it down to “setMovie_(theMovie)” by commenting out certain lines. With it removed it wont play the movie (obviously) but the application no longer freezes.

I’m not sure what your problem is – I just tried it again here, and it works OK. Check that movieView is a proper outlet to your QTMovieView, and try a different movie.

movieView is connected to “Movie View” in my MainMenu.nib. I’ve also tried a number of movie files.

Is there something else i should be doing in xcode to prep for use of a QT Movie View? Maybe “#import <QTKit/QTKit.h>” in my main.m or something like that?

No – you just need to add QTKit.framework to the project. Email me your project if you like.

I will do that right now, then ill update this thread so other people can see what i did wrong. It appears this has been a popular post over the years.

Well the cause of the problem seems to be connected with Auto Layout. Turn that off (select the .xib, go to the File Inspector, and click off the checkbox) and it behaves. I’m not sure whether it’s a particular way you have it set up, but it looks unnecessary for your project anyway.

You also don’t have either garbage collection or ARC turned on, so you’re asking for memory problems.

Didn’t realize you responded here,

Wow, i knew it was going to be something super simple. I’ll do my research on Auto Layout to see what its purpose is (i never turned it on).

I’m very new xcode in general, do you have any links/documents i can use to learn the basics like auto layout?

thank you

Honestly, the two best sources are here and my book.