Friday, April 28, 2017

#1 2010-09-14 05:03:39 am

nebuli
Member
Registered: 2009-04-29
Posts: 3

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

Applescript:


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

Offline

 

#2 2010-09-14 06:36:12 am

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 4998

Re: QTMovieVIew

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


Applescript:

   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 Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2010-09-23 09:08:49 am

nebuli
Member
Registered: 2009-04-29
Posts: 3

Re: QTMovieVIew

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

Offline

 

#4 2012-12-28 04:43:32 pm

Wookie4747
Member
Registered: 2012-12-06
Posts: 11

Re: QTMovieVIew

Shane Stanley wrote:

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


Applescript:

   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_

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.

Offline

 

#5 2012-12-28 05:27:47 pm

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 4998

Re: QTMovieVIew

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#6 2012-12-28 05:37:08 pm

Wookie4747
Member
Registered: 2012-12-06
Posts: 11

Re: QTMovieVIew

Shane Stanley wrote:

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?

Offline

 

#7 2012-12-28 05:40:29 pm

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 4998

Re: QTMovieVIew

Wookie4747 wrote:

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#8 2012-12-28 05:55:45 pm

Wookie4747
Member
Registered: 2012-12-06
Posts: 11

Re: QTMovieVIew

Shane Stanley wrote:

Wookie4747 wrote:

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.

Offline

 

#9 2012-12-28 11:14:20 pm

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 4998

Re: QTMovieVIew

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.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#10 2012-12-30 11:14:41 pm

Wookie4747
Member
Registered: 2012-12-06
Posts: 11

Re: QTMovieVIew

Shane Stanley wrote:

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

Offline

 

#11 2012-12-31 12:32:50 am

Shane Stanley
Member
From: Australia
Registered: 2002-12-07
Posts: 4998

Re: QTMovieVIew

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


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.087 seconds, 9 queries executed ]

RSS (new topics) RSS (active topics)