How to use QuickTime natively under MacOS

Mac OSX specific forum
Niffo
Enthusiast
Enthusiast
Posts: 500
Joined: Tue Jan 31, 2006 9:43 am
Location: France

How to use QuickTime natively under MacOS

Post by Niffo »

Here is an example of the minimum to do to initialise and use QuickTime via the C QT API on MacOS :

Code: Select all

EnableExplicit

ImportC "/System/Library/Frameworks/QuickTime.framework/QuickTime"
   EnterMovies()
   OpenMovieFile(*fileSpec, *resRefNum.w, permission.a)
   NewMovieFromDataRef(*m, flags.w, *id.w, dataRef.l, dataRefType.l)
   QTNewDataReferenceFromFSRef(*fileRef, flags.l, *outDataRef, *outDataRefType)
   CreateMovieControl(theWindow.l, *localRect, theMovie.l, options.l, * returnedControl)
EndImport

ImportC "/System/Library/Frameworks/CoreServices.framework/CoreServices"
   FSPathMakeRef(path.p-utf8, *ref, *isDirectory.b)
EndImport

Structure FSRef
   hidden.a[80]
EndStructure

Structure Rect
   top.w
   left.w
   bottom.w
   right.w
EndStructure

OpenWindow(0, 100, 100, 400, 300, "QuickTime")

Define.FSRef fsRef
Define.l dataRef, dataRefType
Define.l Movie
Define.l MovieControl
Define.Rect rect

EnterMovies()
FSPathMakeRef(OpenFileRequester("","","",0), @fsRef, #Null)
QTNewDataReferenceFromFSRef(@fsRef, 0, @dataRef, @dataRefType)
NewMovieFromDataRef(@Movie, 1, 0, dataRef, dataRefType)
rect\top = 0 : rect\left = 0 : rect\right = WindowWidth(0) : rect\bottom = WindowHeight(0)
CreateMovieControl(WindowID(0), @rect, Movie, 0, @MovieControl)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Niffo
Niffo
Enthusiast
Enthusiast
Posts: 500
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Re: How to use QuickTime natively under MacOS

Post by Niffo »

I am currently trying to work with QuickTime without the use of a "MovieControl". Can someone tell me why the SetMovieGWorld() function generates an "Invalid Memory Access" in the further example ? (If you comment this line, you can hear the movie playing, but without any display).

Code: Select all

EnableExplicit

ImportC "/System/Library/Frameworks/QuickTime.framework/QuickTime"
   EnterMovies()
   OpenMovieFile(*fileSpec, *resRefNum.w, permission.a)
   NewMovieFromDataRef(*m, flags.w, *id.w, dataRef.l, dataRefType.l)
   QTNewDataReferenceFromFSRef(*fileRef, flags.l, *outDataRef, *outDataRefType)
   SetMovieGWorld(theMovie.l, port.l, gdh.l)
   StartMovie(theMovie.l)
EndImport

ImportC "/System/Library/Frameworks/CoreServices.framework/CoreServices"
   FSPathMakeRef(path.p-utf8, *ref, *isDirectory.b)
EndImport

Structure FSRef
   hidden.a[80]
EndStructure

OpenWindow(0, 100, 100, 400, 300, "QuickTime")

Define.FSRef fsRef
Define.l dataRef, dataRefType
Define.l Movie

EnterMovies()
FSPathMakeRef(OpenFileRequester("","","",0), @fsRef, #Null)
QTNewDataReferenceFromFSRef(@fsRef, 0, @dataRef, @dataRefType)
NewMovieFromDataRef(@Movie, 1, 0, dataRef, dataRefType)
SetMovieGWorld(Movie, WindowID(0), #Null)
StartMovie(Movie)

Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
Niffo
Niffo
Enthusiast
Enthusiast
Posts: 500
Joined: Tue Jan 31, 2006 9:43 am
Location: France

Re: How to use QuickTime natively under MacOS

Post by Niffo »

Niffo
Post Reply