[SOLVED] QTKit : Creating and saving a movie Reference to an URL
[SOLVED] QTKit : Creating and saving a movie Reference to an URL
- Subject: [SOLVED] QTKit : Creating and saving a movie Reference to an URL
- From: "Pascal Vuylsteker" <email@hidden>
- Date: Fri, 17 Nov 2006 12:05:27 +0100
In regard to my previous mail, I solved the issue (creating a movie
reference from an URL to a media file), especially thanks to those two
documents :
http://developer.apple.com/technotes/tn2005/tn2138.html#TNTAG11
and
http://developer.apple.com/qa/qa2006/qa1469.html
In summary, when you want to create a Quicktime reference movie, you
have to load all of your media first.
The normal behavior is that QTKit will give you back an handle on your
movie, even if it hasn't finished downloading it. So you have to wait
for the download to be completed.
One interesting trick is that even if you ask for for a synchronous
download, you will get a hand on your movie as soon as you are able to
play it, which is fair enough, but which still could be before the end
of the full download.
So, you will still have to wait for the end of the download to be able
to save a refence to your source media.
Here is the working code :
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
[NSURL URLWithString:URLpath], QTMovieURLAttribute,
[NSNumber numberWithBool:NO], QTMovieOpenAsyncOKAttribute,
nil];
movie = [[QTMovie movieWithAttributes:attrs error:&theError] retain];
if ( movie == nil ) {
NSLog([NSString stringWithFormat: @"Error reading file : \n %@",
[theError localizedFailureReason]]);
// maybe try to determine cause of error and recover first
} else {
NSLog([NSString stringWithFormat:@"A movie had been open from an URL
: %@", [[movie attributeForKey:QTMovieURLAttribute]
absoluteString]]);
movieLoadState = [[movie attributeForKey:QTMovieLoadStateAttribute]
longValue];
if (movieLoadState == kMovieLoadStateError) {
NSLog(@"Loading error. Operation cancelled");
return (-1);
}
while (movieLoadState < kMovieLoadStateComplete) {
NSLog([NSString stringWithFormat:@"Loading state value (< 100 000)
: %d", movieLoadState]);
sleep(5);
movieLoadState = [[movie attributeForKey:QTMovieLoadStateAttribute]
longValue];
}
NSMutableDictionary *savedMovieAttributes = [NSDictionary
dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], QTMovieFlatten,
[NSNumber numberWithBool:NO], QTMovieExport
, nil];
if([movie writeToFile:moviePath
withAttributes:savedMovieAttributes])
NSLog([NSString stringWithFormat: @"The movie was written to file
%@", moviePath]);
else
NSLog([NSString stringWithFormat: @"Bug when writing the file %@",
moviePath]);
---
Pascal Vuylsteker - http://www.vrarchitect.net/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden