Conversion to AVKit more or less works

This commit is contained in:
Matthias Neeracher 2016-10-03 03:26:35 +02:00
parent 0fb5718725
commit e3fb8d3425
20 changed files with 697 additions and 4589 deletions

View File

@ -7,6 +7,8 @@
objects = {
/* Begin PBXBuildFile section */
950737F11D5FAA0F00737CDE /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 950737F01D5FAA0F00737CDE /* AVFoundation.framework */; };
950737F31D5FAA1600737CDE /* AVKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 950737F21D5FAA1600737CDE /* AVKit.framework */; };
950BB66B13F1F26200D8E669 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 950BB66A13F1F26200D8E669 /* Cocoa.framework */; };
950BB67513F1F26200D8E669 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 950BB67313F1F26200D8E669 /* InfoPlist.strings */; };
950BB67713F1F26200D8E669 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 950BB67613F1F26200D8E669 /* main.m */; };
@ -16,7 +18,6 @@
950BB68413F1F26200D8E669 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 950BB68213F1F26200D8E669 /* MainMenu.xib */; };
950BB68713F1F26200D8E669 /* MADocument.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = 950BB68513F1F26200D8E669 /* MADocument.xcdatamodeld */; };
950BB68F13F1F29D00D8E669 /* CoreData.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 950BB68D13F1F29D00D8E669 /* CoreData.framework */; };
950BB69013F1F29D00D8E669 /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 950BB68E13F1F29D00D8E669 /* QTKit.framework */; };
950BB69A13F2C6B400D8E669 /* MATag.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB69913F2C6B400D8E669 /* MATag.mm */; };
950BB69D13F2C6B400D8E669 /* MAAnno.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB69C13F2C6B400D8E669 /* MAAnno.mm */; };
950BB6A013F2C6B400D8E669 /* MAMedia.mm in Sources */ = {isa = PBXBuildFile; fileRef = 950BB69F13F2C6B400D8E669 /* MAMedia.mm */; };
@ -50,6 +51,8 @@
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
950737F01D5FAA0F00737CDE /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; };
950737F21D5FAA1600737CDE /* AVKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVKit.framework; path = System/Library/Frameworks/AVKit.framework; sourceTree = SDKROOT; };
950BB66613F1F26200D8E669 /* Medianno.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Medianno.app; sourceTree = BUILT_PRODUCTS_DIR; };
950BB66A13F1F26200D8E669 /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
950BB67213F1F26200D8E669 /* Medianno-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Medianno-Info.plist"; sourceTree = "<group>"; };
@ -63,7 +66,6 @@
950BB68313F1F26200D8E669 /* en */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = en; path = en.lproj/MainMenu.xib; sourceTree = "<group>"; };
950BB68613F1F26200D8E669 /* MADocument.xcdatamodel */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcdatamodel; path = MADocument.xcdatamodel; sourceTree = "<group>"; };
950BB68D13F1F29D00D8E669 /* CoreData.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreData.framework; path = System/Library/Frameworks/CoreData.framework; sourceTree = SDKROOT; };
950BB68E13F1F29D00D8E669 /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = System/Library/Frameworks/QTKit.framework; sourceTree = SDKROOT; };
950BB69813F2C6B400D8E669 /* MATag.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MATag.h; sourceTree = "<group>"; };
950BB69913F2C6B400D8E669 /* MATag.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MATag.mm; sourceTree = "<group>"; };
950BB69B13F2C6B400D8E669 /* MAAnno.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MAAnno.h; sourceTree = "<group>"; };
@ -116,8 +118,9 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
950737F31D5FAA1600737CDE /* AVKit.framework in Frameworks */,
950737F11D5FAA0F00737CDE /* AVFoundation.framework in Frameworks */,
950BB68F13F1F29D00D8E669 /* CoreData.framework in Frameworks */,
950BB69013F1F29D00D8E669 /* QTKit.framework in Frameworks */,
950BB66B13F1F26200D8E669 /* Cocoa.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -145,8 +148,9 @@
950BB66913F1F26200D8E669 /* Frameworks */ = {
isa = PBXGroup;
children = (
950737F21D5FAA1600737CDE /* AVKit.framework */,
950737F01D5FAA0F00737CDE /* AVFoundation.framework */,
950BB68D13F1F29D00D8E669 /* CoreData.framework */,
950BB68E13F1F29D00D8E669 /* QTKit.framework */,
950BB66A13F1F26200D8E669 /* Cocoa.framework */,
);
name = Frameworks;
@ -505,11 +509,11 @@
950BB68B13F1F26200D8E669 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Medianno/Medianno-Prefix.pch";
INFOPLIST_FILE = "Medianno/Medianno-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_BUNDLE_IDENTIFIER = "org.aereperennius.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
@ -520,11 +524,11 @@
950BB68C13F1F26200D8E669 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CLANG_ENABLE_OBJC_ARC = YES;
GCC_ENABLE_OBJC_GC = unsupported;
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "Medianno/Medianno-Prefix.pch";
INFOPLIST_FILE = "Medianno/Medianno-Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.7;
PRODUCT_BUNDLE_IDENTIFIER = "org.aereperennius.${PRODUCT_NAME:rfc1034identifier}";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;

View File

@ -50,7 +50,6 @@ static NSDictionary * sDateHypotheses;
{
[self window];
[self willChangeValueForKey:@"dateFormats"];
[dateFormats release];
dateFormats = nil;
while ([dateFormatMenu numberOfItems] > 2)
[dateFormatMenu removeItemAtIndex:2];
@ -104,7 +103,7 @@ static NSDictionary * sDateHypotheses;
}
}
if ([formats count] > 0)
dateFormats = [formats retain];
dateFormats = formats;
[self didChangeValueForKey:@"dateFormats"];
}
@ -116,7 +115,7 @@ static NSDictionary * sDateHypotheses;
[m addObject:[NSMutableDictionary dictionaryWithObject:url forKey:@"url"]];
media = m;
[self useModificationDates:self];
[NSApp beginSheet:[self window] modalForWindow:[parent window] didEndBlock:^(NSInteger returnCode) {
[[parent window] beginSheet:[self window] completionHandler:^(NSModalResponse returnCode) {
if (returnCode == NSAlertFirstButtonReturn) {
MADocument * doc = [parent document];
[media enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) {
@ -127,8 +126,6 @@ static NSDictionary * sDateHypotheses;
}];
}
[[self window] orderOut:self];
[self autorelease];
[media release];
media = nil;
}];
}

View File

@ -8,21 +8,19 @@
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <QTKit/QTKit.h>
@class MATag;
@class MAMedia;
@class MADocument;
@interface MAAnno : NSManagedObject {
@private
}
@property (nonatomic, retain) NSString * location;
@property (nonatomic, retain) NSString * notes;
@property (nonatomic, retain) NSSet *tags;
@property (nonatomic, retain) NSManagedObject *media;
- (QTTime)qtLocation;
- (CFTimeInterval)avLocation;
- (NSString *)exportText;
- (MAAnno *)copyToDocument:(MADocument *)doc withMedia:(MAMedia *)media;

View File

@ -10,6 +10,7 @@
#import "MATag.h"
#import "MATagDescription.h"
#import "MADocument.h"
#import "MAShortenQTTime.h"
#import <vector>
@ -33,20 +34,14 @@
- (id)initWithArray:(NSArray *)array
{
contents = [array retain];
contents = array;
return self;
}
- (void)dealloc
{
[contents release];
[super dealloc];
}
+ (id)arrayWithArray:(NSArray *)array
{
return [[[MANotAnArray alloc] initWithArray:array] autorelease];
return [[MANotAnArray alloc] initWithArray:array];
}
- (BOOL)isEqual:(id)object
@ -76,9 +71,9 @@
@dynamic tags;
@dynamic media;
- (QTTime)qtLocation
- (CFTimeInterval)avLocation;
{
return QTTimeFromString(self.location);
return MATimeFromString(self.location);
}
- (NSArray *)tagDescriptions
@ -126,7 +121,7 @@
- (MAAnno *)copyToDocument:(MADocument *)doc withMedia:(MAMedia *)media;
{
MAAnno * anno = [doc addAnnotationForMedia:media location:QTTimeFromString(self.location)];
MAAnno * anno = [doc addAnnotationForMedia:media location:MATimeFromString(self.location)];
anno.notes = self.notes;
NSMutableArray * tagDescs = [NSMutableArray array];
for (MATagDescription * tag in self.tagDescriptions)

View File

@ -12,14 +12,6 @@
@class MAMovieWindow;
@class MATagWindow;
typedef void (^MASheetBlock)(NSInteger returnCode);
@interface NSApplication (SheetAdditions)
- (void)beginSheet: (NSWindow *)sheet modalForWindow:(NSWindow *)docWindow didEndBlock: (MASheetBlock)block;
@end
@interface MAAppController : NSObject <NSApplicationDelegate> {
}

View File

@ -18,23 +18,3 @@
}
@end
@implementation NSApplication (SheetAdditions)
- (void)beginSheet: (NSWindow *)sheet modalForWindow:(NSWindow *)docWindow didEndBlock: (MASheetBlock)block
{
[self beginSheet: sheet
modalForWindow: docWindow
modalDelegate: self
didEndSelector: @selector(my_blockSheetDidEnd:returnCode:contextInfo:)
contextInfo: Block_copy(block)];
}
- (void)my_blockSheetDidEnd: (NSWindow *)sheet returnCode: (NSInteger)returnCode contextInfo: (void *)contextInfo
{
MASheetBlock block = (MASheetBlock)contextInfo;
block(returnCode);
Block_release(block);
}
@end

View File

@ -7,8 +7,7 @@
//
#import "MAColorForURL.h"
#import <QTKit/QTKit.h>
#import <AVFoundation/AVFoundation.h>
@implementation MAColorForURL
@ -25,7 +24,7 @@
- (id)transformedValue:(id)value
{
NSURL * mediaURL = [NSURL URLWithString:value];
if ([QTMovie canInitWithURL:mediaURL])
if ([[AVAsset assetWithURL:mediaURL] isPlayable])
return [NSColor blackColor];
else
return [NSColor redColor];

View File

@ -7,7 +7,8 @@
//
#import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h>
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>
@class MAMovieWindow;
@class MAMedia;
@ -17,18 +18,18 @@
{
IBOutlet NSArrayController* mediaController;
IBOutlet NSArrayController* annotationController;
IBOutlet QTMovieView * movieView;
IBOutlet AVPlayerView * movieView;
IBOutlet NSTableView * mediaTable;
IBOutlet NSTableView * annotationTable;
IBOutlet NSView * textExportAccessoryView;
QTMovie * currentMovie;
AVPlayer * currentMovie;
NSString * currentMovieTitle;
QTTime lastMovieTime;
}
@property BOOL exportAnnotations;
@property BOOL exportTags;
@property (nonatomic,retain)NSString * searchString;
@property (readonly) NSNumber * currentMovieTime;
- (IBAction)addMediaFiles:(id)sender;
- (IBAction)importText:(id)sender;
@ -40,7 +41,6 @@
- (IBAction)mediaSkipForward:(id)sender;
- (IBAction)toggleMediaPlay:(id)sender;
- (IBAction)delete:(id)sender;
- (QTTime)currentMovieTime;
- (void)moviePanelDidAppear;
- (void)moviePanelDidClose;
- (MAMedia *)currentMedia;

View File

@ -6,8 +6,6 @@
// Copyright 2011 Matthias Neeracher. All rights reserved.
//
#import <QTKit/QTKit.h>
#import "MADocWindow.h"
#import "MAAddMediaSheet.h"
#import "MADocument.h"
@ -19,6 +17,7 @@
#import "MATagWindow.h"
#import "MAAppController.h"
#import "MADragging.h"
#import "MAShortenQTTime.h"
#include <algorithm>
@ -38,19 +37,11 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
return self;
}
- (void)dealloc
{
[currentMovie release];
[searchString release];
[super dealloc];
}
- (void)windowDidLoad
{
[super windowDidLoad];
[mediaController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"date" ascending:YES]]];
[annotationController setSortDescriptors:[NSArray arrayWithObject:[NSSortDescriptor sortDescriptorWithKey:@"location" ascending:YES]]];
[NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(updateMovieTime:) userInfo:nil repeats:YES];
[mediaController addObserver:self forKeyPath:@"selection.media" options:0 context:&kMADocWindowObserver];
[mediaController addObserver:self forKeyPath:@"selection.name" options:0 context:&kMADocWindowObserver];
[self registerOurDragTypes];
@ -68,9 +59,9 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
- (void)moviePanelDidAppear
{
[movieView setMovie:nil];
[movieView setPlayer:nil];
if (![[self moviePanel] shouldDisplayMovie:currentMovie withTitle:currentMovieTitle])
[movieView setMovie:currentMovie];
[movieView setPlayer:currentMovie];
}
- (void)windowDidBecomeMain:(NSNotification *)notification
@ -82,7 +73,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
- (void)moviePanelDidClose
{
[[self moviePanel] shouldDisplayMovie:nil withTitle:@""];
[movieView setMovie:currentMovie];
[movieView setPlayer:currentMovie];
}
- (void)windowDidResignMain:(NSNotification *)notification
@ -98,17 +89,16 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
//
// Current movie changed
//
[currentMovie release];
[self willChangeValueForKey:@"currentMovie"];
if (MAMedia * currentMedia = [self currentMedia]) {
NSURL * mediaURL = [NSURL URLWithString:[currentMedia media]];
currentMovie = [[QTMovie alloc] initWithURL:mediaURL error:nil];
currentMovie = [AVPlayer playerWithURL:mediaURL];
currentMovieTitle = [currentMedia name];
} else {
currentMovie = nil;
currentMovieTitle = @"";
}
lastMovieTime = QTMakeTime(-1, 600);
[self updateMovieTime:nil];
[self didChangeValueForKey:@"currentMovie"];
}
[self moviePanelDidAppear];
}
@ -124,25 +114,22 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
return nil;
}
- (QTTime)currentMovieTime
+ (NSSet *)keyPathsForValuesAffectingCurrentMovieTime
{
return [currentMovie currentTime];
return [NSSet setWithObject:@"currentMovie.currentTime"];
}
- (void)updateMovieTime:(NSTimer *)timer
- (NSNumber *)currentMovieTime
{
QTTime currentTime = [self currentMovieTime];
if (QTTimeCompare(currentTime, lastMovieTime)) {
[self willChangeValueForKey:@"currentMovieTime"];
lastMovieTime = currentTime;
[self didChangeValueForKey:@"currentMovieTime"];
}
CMTime time = [currentMovie currentTime];
return [NSNumber numberWithDouble:(double)time.value/time.timescale];
}
- (IBAction)addMediaFiles:(id)sender
{
NSOpenPanel * openPanel = [NSOpenPanel openPanel];
[openPanel setAllowedFileTypes:[QTMovie movieFileTypes:QTIncludeCommonTypes]];
[openPanel setAllowedFileTypes:[AVMovie movieTypes]];
[openPanel setAllowsMultipleSelection:YES];
[openPanel setCanChooseDirectories:YES];
[openPanel beginSheetModalForWindow:[self window] completionHandler:^(NSInteger result) {
@ -180,7 +167,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
NSNumber * isDirectory;
[url getResourceValue:&isDirectory forKey:NSURLIsDirectoryKey error:nil];
if ([isDirectory boolValue]) {
[self addMediaTypes:[QTMovie movieFileTypes:QTIncludeCommonTypes] inDirectory:url toList:expandedURLs];
[self addMediaTypes:[AVMovie movieTypes] inDirectory:url toList:expandedURLs];
continue;
}
}
@ -189,6 +176,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
[[[MAAddMediaSheet alloc] init] runWithParentWindow:self media:expandedURLs];
}
#if 0
- (void)exportMediaToURL:(NSURL *)url
{
NSIndexSet * selection = [annotationController selectionIndexes];
@ -257,6 +245,8 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
}];
}
#endif
- (void)delete:(id)sender
{
NSResponder * responder = [[self window] firstResponder];
@ -275,7 +265,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
- (IBAction)toggleMediaPlay:(id)sender
{
if ([currentMovie rate] > 0.0f)
[currentMovie stop];
[currentMovie pause];
else
[currentMovie play];
}
@ -316,7 +306,7 @@ static const char * kMADocWindowObserver = "MADocWindowObserver";
#pragma mark Media navigation
static NSTimeInterval sLastSkip = 0.0;
static CFTimeInterval sLastSkip = 0.0;
- (void)resetSkipFactor:(id)sender
{
@ -325,17 +315,12 @@ static NSTimeInterval sLastSkip = 0.0;
- (void)skipTimeInterval
{
QTTime interval = QTMakeTimeWithTimeInterval(fabs(sLastSkip));
QTTime current = [currentMovie currentTime];
if (sLastSkip > 0)
current = QTTimeIncrement(current, interval);
else
current = QTTimeDecrement(current, interval);
[currentMovie setCurrentTime:current];
CMTime current = [currentMovie currentTime];
current.value += static_cast<CMTimeValue>(sLastSkip*current.timescale);
[currentMovie seekToTime:current];
sLastSkip *= 1.1;
[NSRunLoop cancelPreviousPerformRequestsWithTarget:self selector:@selector(resetSkipFactor:) object:self];
[self performSelector:@selector(resetSkipFactor:) withObject:self afterDelay:0.5];
[self updateMovieTime:nil];
}
- (IBAction)mediaSkipBackward:(id)sender
@ -395,15 +380,20 @@ static NSTimeInterval sLastSkip = 0.0;
{
NSArray * selection = [annotationController selectedObjects];
if ([selection count])
if (MAAnno * firstSelectedAnno = [selection objectAtIndex:0])
[currentMovie setCurrentTime:[firstSelectedAnno qtLocation]];
if (MAAnno * firstSelectedAnno = [selection objectAtIndex:0]) {
CFTimeInterval avLocation = [firstSelectedAnno avLocation];
CMTime newTime = currentMovie.currentTime;
newTime.value = static_cast<CMTimeValue>(avLocation*newTime.timescale);
[currentMovie seekToTime:newTime];
}
}
- (IBAction)addAnnotation:(id)sender
{
[currentMovie stop];
QTTime location = [self currentMovieTime];
MAAnno * anno = [[self document] addAnnotationForMedia:[self currentMedia] location:location];
[currentMovie pause];
CMTime time = currentMovie.currentTime;
CFTimeInterval loc = static_cast<CFTimeInterval>(time.value)/time.timescale;
MAAnno * anno = [[self document] addAnnotationForMedia:[self currentMedia] location:loc];
[annotationController setSelectedObjects:[NSArray arrayWithObject:anno]];
[annotationTable editColumn:[annotationTable columnWithIdentifier:@"tags"]
row:[annotationController selectionIndex]
@ -484,8 +474,8 @@ static NSTimeInterval sLastSkip = 0.0;
} else if (nextIsTag) {
if (!media)
break;
QTTime location= QTTimeFromString([components objectAtIndex:0]);
MAAnno * anno = [doc addAnnotationForMedia:media location:location];
CFTimeInterval location = MATimeFromString([components objectAtIndex:0]);
MAAnno * anno = [doc addAnnotationForMedia:media location:location];
[anno setNotes:[components objectAtIndex:1]];
NSMutableArray * tagDescs = [NSMutableArray array];
for (NSUInteger i = 2; i<numComp; ++i)
@ -517,8 +507,7 @@ static NSTimeInterval sLastSkip = 0.0;
{
[self willChangeValueForKey:@"searchString"];
if (searchString != str) {
[searchString release];
searchString = [str retain];
searchString = str;
}
if (!searchString || [searchString isEqual:@""]) {
[mediaController setFilterPredicate:nil];

View File

@ -7,7 +7,6 @@
//
#import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h>
@class MAMedia;
@class MATagDescription;
@ -18,7 +17,7 @@
}
- (MAMedia *)addMediaURL:(NSURL *)url name:(NSString *)name date:(NSDate *)date;
- (MAAnno *)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location;
- (MAAnno *)addAnnotationForMedia:(MAMedia *)media location:(CFTimeInterval)location;
- (MATagDescription *)tagDescriptionForName:(NSString *)name;
- (MATagDescription *)tagDescriptionForName:(NSString *)name notes:(NSString *)notes;
- (NSArray *)tagNamesMatchingPrefix:(NSString *)prefix;

View File

@ -11,6 +11,7 @@
#import "MAMedia.h"
#import "MAAnno.h"
#import "MATagDescription.h"
#import "MAShortenQTTime.h"
#pragma mark MADocument
@ -31,7 +32,6 @@
{
MADocWindow * windowController = [[MADocWindow alloc] initWithWindowNibName:[self windowNibName]];
[self addWindowController:windowController];
[windowController release];
}
+ (BOOL)autosavesInPlace
@ -81,12 +81,12 @@
#pragma mark Annotation management
- (MAAnno *)addAnnotationForMedia:(MAMedia *)media location:(QTTime)location
- (MAAnno *)addAnnotationForMedia:(MAMedia *)media location:(CFTimeInterval)location
{
NSManagedObjectContext *moc = [self managedObjectContext];
MAAnno * annotation = [NSEntityDescription insertNewObjectForEntityForName:@"MAAnno" inManagedObjectContext:moc];
annotation.media = media;
annotation.location = QTStringFromTime(location);
annotation.location = MAStringFromTime(location);
annotation.notes = @"";
return annotation;

View File

@ -10,12 +10,14 @@
#import "MATagDescription.h"
#import "MAAnno.h"
#import "MAMedia.h"
#import "MADocument.h"
#include <algorithm>
#define kMADragType @"org.aereperennius.medianno"
static NSPointerArray * sValidPasteboardData;
static NSArray * sCurrentPasteboardData;
static long sPasteboardGeneration = 0;
@interface MAPasteboardData : NSObject <NSPasteboardWriting> {
NSArray * contents;
@ -31,29 +33,25 @@ static NSPointerArray * sValidPasteboardData;
- (id)initWithArray:(NSArray *)array
{
if (!sValidPasteboardData)
sValidPasteboardData = [[NSPointerArray alloc] initWithOptions:NSPointerFunctionsZeroingWeakMemory];
self = [super init];
contents = array;
if ([sValidPasteboardData count] > 10)
[sValidPasteboardData compact];
[sValidPasteboardData addPointer:contents];
sCurrentPasteboardData = contents;
++sPasteboardGeneration;
return self;
}
+ (id)pasteboardDataWithArray:(NSArray *)array
{
return [[[MAPasteboardData alloc] initWithArray:array] autorelease];
return [[MAPasteboardData alloc] initWithArray:array];
}
+ (NSArray *)arrayFromPasteboard:(NSPasteboard *)pboard
{
if (NSNumber * drag = [pboard propertyListForType:kMADragType]) {
NSArray * possibleArray = (NSArray *)[drag longValue];
for (NSUInteger count = [sValidPasteboardData count]; count--; )
if ([sValidPasteboardData pointerAtIndex:count] == possibleArray)
return possibleArray;
if (sPasteboardGeneration == [drag longValue]) {
return sCurrentPasteboardData;
}
}
return nil;
}
@ -77,7 +75,7 @@ static NSPointerArray * sValidPasteboardData;
- (id)pasteboardPropertyListForType:(NSString *)type
{
if ([type isEqual:kMADragType]) {
return [NSNumber numberWithLong:(long)contents];
return [NSNumber numberWithLong:sPasteboardGeneration];
} else if ([type isEqual:(NSString *)kUTTypeUTF8PlainText]) {
NSMutableString * stringBuffer = [NSMutableString string];
for (id obj in contents)

View File

@ -8,7 +8,6 @@
#import <Foundation/Foundation.h>
#import <CoreData/CoreData.h>
#import <QTKit/QTKit.h>
@class MAAnno, MADocument;

View File

@ -7,13 +7,14 @@
//
#import <Cocoa/Cocoa.h>
#import <QTKit/QTKit.h>
#import <AVKit/AVKit.h>
#import <AVFoundation/AVFoundation.h>
@interface MAMovieWindow : NSWindowController <NSWindowDelegate> {
IBOutlet QTMovieView * panelMovieView;
IBOutlet AVPlayerView * panelMovieView;
}
- (BOOL)shouldDisplayMovie:(QTMovie *)movie withTitle:(NSString *)title;
- (BOOL)shouldDisplayMovie:(AVPlayer *)movie withTitle:(NSString *)title;
- (IBAction)toggleWindow:(id)sender;
@end

View File

@ -23,14 +23,14 @@
[super windowDidLoad];
}
- (BOOL)shouldDisplayMovie:(QTMovie *)movie withTitle:(NSString *)title
- (BOOL)shouldDisplayMovie:(AVPlayer *)movie withTitle:(NSString *)title
{
if ([self isWindowLoaded] && [[self window] isVisible]) {
[panelMovieView setMovie:movie];
[panelMovieView setPlayer:movie];
[[self window] setTitle:title];
return YES;
} else {
[panelMovieView setMovie:nil];
[panelMovieView setPlayer:nil];
[[self window] setTitle:@""];
return NO;
}
@ -60,4 +60,4 @@
return NO;
}
@end
@end

View File

@ -8,6 +8,9 @@
#import <Foundation/Foundation.h>
NSString * MAStringFromTime(CFTimeInterval time);
CFTimeInterval MATimeFromString(NSString * timeStr);
@interface MAShortenQTTime : NSValueTransformer
@end

View File

@ -7,7 +7,45 @@
//
#import "MAShortenQTTime.h"
#import <QTKit/QTKit.h>
NSString * MAStringFromTime(CFTimeInterval time)
{
const char * sign = "";
if (time < 0) {
sign = "-";
time = -time;
}
NSUInteger seconds = (NSUInteger)time;
NSUInteger millis = (NSUInteger)((time-seconds)*1000);
NSUInteger minutes = seconds / 60;
seconds %= 60;
NSUInteger hours = minutes / 60;
minutes %= 60;
NSUInteger days = hours / 24;
hours %= 24;
return [NSString stringWithFormat:@"%s%tu:%02tu:%02tu:%02tu.%03tu/600", sign, days, hours, minutes, seconds, millis];
}
CFTimeInterval MATimeFromString(NSString * timeStr)
{
const char * time = [timeStr UTF8String];
int sign = 1;
if (time[0] == '-') {
++time;
sign = -1;
}
NSInteger days, hours, minutes;
double seconds;
if (sscanf(time, "%td:%td:%td:%lf", &days, &hours, &minutes, &seconds) == 4)
return sign*(((days*24 + hours)*60 + minutes)*60 + seconds);
else
return -1.0;
}
@implementation MAShortenQTTime
@ -21,31 +59,25 @@
return NO;
}
- (id)transformedValue:(id)value {
NSString * fullTime = [value isKindOfClass:[NSString class]] ? value : QTStringFromTime([value QTTimeValue]);
NSRange rangeToUse = {0,0};
//
// Trim leading zeros, up to a point
//
while (rangeToUse.location < 6) {
switch ([fullTime characterAtIndex:rangeToUse.location]) {
case '0':
case ':':
++rangeToUse.location;
continue;
- (id)transformedValue:(id)value
{
NSUInteger seconds = [value unsignedIntegerValue];
if (NSUInteger minutes = seconds/60) {
seconds %= 60;
if (NSUInteger hours = minutes/60) {
minutes %= 60;
if (NSUInteger days = hours/24) {
hours %= 24;
return [NSString stringWithFormat:@"%tu:%02tu:%02tu:%02tu", days, hours, minutes, seconds];
} else {
return [NSString stringWithFormat:@"%tu:%02tu:%02tu", hours, minutes, seconds];
}
} else {
return [NSString stringWithFormat:@"%tu:%02tu", minutes, seconds];
}
break;
} else {
return [NSString stringWithFormat:@"0:%02tu", seconds];
}
//
// Trim fractions of seconds
//
for (rangeToUse.length = [fullTime length]-rangeToUse.location; rangeToUse.length-- > 0; )
if ([fullTime characterAtIndex:rangeToUse.location+rangeToUse.length] == '.')
break;
if (!rangeToUse.length)
rangeToUse.length = [fullTime length]-rangeToUse.location;
return [fullTime substringWithRange:rangeToUse];
}
@end

View File

@ -15,7 +15,7 @@ static NSCharacterSet * sOverrideTokenizingCharacters;
- (NSCharacterSet *)tokenizingCharacterSet
{
if (!sOverrideTokenizingCharacters)
sOverrideTokenizingCharacters = [[NSCharacterSet characterSetWithCharactersInString:@";"] retain];
sOverrideTokenizingCharacters = [NSCharacterSet characterSetWithCharactersInString:@";"];
return sOverrideTokenizingCharacters;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,277 +1,37 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="7.10">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11B26</string>
<string key="IBDocument.InterfaceBuilderVersion">1617</string>
<string key="IBDocument.AppKitVersion">1138</string>
<string key="IBDocument.HIToolboxVersion">566.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.QTKitIBPlugin</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>1617</string>
<string>518</string>
</object>
</object>
<object class="NSArray" key="IBDocument.IntegratedClassDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSWindowTemplate</string>
<string>NSView</string>
<string>QTMovieView</string>
<string>NSCustomObject</string>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.QTKitIBPlugin</string>
</object>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys" id="0">
<bool key="EncodedWithXMLCoder">YES</bool>
</object>
<reference key="dict.values" ref="0"/>
</object>
<object class="NSMutableArray" key="IBDocument.RootObjects" id="1000">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSCustomObject" id="1001">
<string key="NSClassName">MAMovieWindow</string>
</object>
<object class="NSCustomObject" id="1003">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1004">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSWindowTemplate" id="633460828">
<int key="NSWindowStyleMask">95</int>
<int key="NSWindowBacking">2</int>
<string key="NSWindowRect">{{1887, 836}, {640, 496}}</string>
<int key="NSWTFlags">-1540357120</int>
<string key="NSWindowTitle">Window</string>
<string key="NSWindowClass">MAMovieWin</string>
<nil key="NSViewClass"/>
<nil key="NSUserInterfaceItemIdentifier"/>
<object class="NSView" key="NSWindowView" id="607284987">
<reference key="NSNextResponder"/>
<int key="NSvFlags">256</int>
<object class="NSMutableArray" key="NSSubviews">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="QTMovieView" id="187692734">
<reference key="NSNextResponder" ref="607284987"/>
<int key="NSvFlags">274</int>
<object class="NSMutableSet" key="NSDragTypes">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="set.sortedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>Apple URL pasteboard type</string>
<string>CorePasteboardFlavorType 0x6D6F6F76</string>
<string>NSFilenamesPboardType</string>
<string>QTMoviePasteboardType</string>
</object>
</object>
<string key="NSFrameSize">{640, 496}</string>
<reference key="NSSuperview" ref="607284987"/>
<string key="NSReuseIdentifierKey">_NS:46</string>
<object class="NSColor" key="kCoderFillColor">
<int key="NSColorSpace">3</int>
<bytes key="NSWhite">MAA</bytes>
</object>
<boolean value="YES" key="kCoderControllerVisible"/>
<boolean value="YES" key="kCoderPreservesAspectRatio"/>
<nil key="kCoderMovie"/>
<boolean value="NO" key="kCoderEditable"/>
</object>
</object>
<string key="NSFrameSize">{640, 496}</string>
<reference key="NSSuperview"/>
<reference key="NSNextKeyView" ref="187692734"/>
<string key="NSReuseIdentifierKey">_NS:2837</string>
</object>
<string key="NSScreenRect">{{0, 0}, {2560, 1418}}</string>
<string key="NSMaxSize">{10000000000000, 10000000000000}</string>
<string key="NSFrameAutosaveName">MAMoviePanel</string>
<bool key="NSWindowIsRestorable">YES</bool>
</object>
</object>
<object class="IBObjectContainer" key="IBDocument.Objects">
<object class="NSMutableArray" key="connectionRecords">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="633460828"/>
</object>
<int key="connectionID">5</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">panelMovieView</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="187692734"/>
</object>
<int key="connectionID">12</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="633460828"/>
<reference key="destination" ref="1001"/>
</object>
<int key="connectionID">13</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
<object class="NSArray" key="orderedObjects">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBObjectRecord">
<int key="objectID">0</int>
<reference key="object" ref="0"/>
<reference key="children" ref="1000"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1001"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1003"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1004"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">3</int>
<reference key="object" ref="633460828"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="607284987"/>
</object>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">4</int>
<reference key="object" ref="607284987"/>
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="187692734"/>
</object>
<reference key="parent" ref="633460828"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">6</int>
<reference key="object" ref="187692734"/>
<reference key="parent" ref="607284987"/>
<string key="objectName">Movie View</string>
</object>
</object>
</object>
<object class="NSMutableDictionary" key="flattenedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>-1.IBPluginDependency</string>
<string>-2.IBPluginDependency</string>
<string>-3.IBPluginDependency</string>
<string>3.IBNSWindowAutoPositionCentersHorizontal</string>
<string>3.IBNSWindowAutoPositionCentersVertical</string>
<string>3.IBPluginDependency</string>
<string>3.NSWindowTemplate.visibleAtLaunch</string>
<string>4.IBPluginDependency</string>
<string>6.IBPluginDependency</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO"/>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<boolean value="NO"/>
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
<string>com.apple.QTKitIBPlugin</string>
</object>
</object>
<object class="NSMutableDictionary" key="unlocalizedProperties">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="activeLocalization"/>
<object class="NSMutableDictionary" key="localizations">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference key="dict.sortedKeys" ref="0"/>
<reference key="dict.values" ref="0"/>
</object>
<nil key="sourceID"/>
<int key="maxID">13</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="IBPartialClassDescription">
<string key="className">MAMovieWin</string>
<string key="superclassName">NSPanel</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MAMovieWin.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">MAMovieWindow</string>
<string key="superclassName">NSWindowController</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">toggleWindow:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">toggleWindow:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">toggleWindow:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="NSMutableDictionary" key="outlets">
<string key="NS.key.0">panelMovieView</string>
<string key="NS.object.0">QTMovieView</string>
</object>
<object class="NSMutableDictionary" key="toOneOutletInfosByName">
<string key="NS.key.0">panelMovieView</string>
<object class="IBToOneOutletInfo" key="NS.object.0">
<string key="name">panelMovieView</string>
<string key="candidateClassName">QTMovieView</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/MAMovieWindow.h</string>
</object>
</object>
</object>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="3000" key="NS.object.0"/>
</object>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11191" systemVersion="16A323" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
<dependencies>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.AVKitIBPlugin" version="11191"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11191"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="MAMovieWindow">
<connections>
<outlet property="panelMovieView" destination="s8w-Lv-MOu" id="eOg-QR-Hs2"/>
<outlet property="window" destination="3" id="5"/>
</connections>
</customObject>
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
<customObject id="-3" userLabel="Application"/>
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" hidesOnDeactivate="YES" oneShot="NO" showsToolbarButton="NO" visibleAtLaunch="NO" frameAutosaveName="MAMoviePanel" animationBehavior="default" id="3" customClass="MAMovieWin">
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES" utility="YES" documentModal="YES"/>
<windowPositionMask key="initialPositionMask" rightStrut="YES" topStrut="YES"/>
<rect key="contentRect" x="1887" y="836" width="640" height="496"/>
<rect key="screenRect" x="0.0" y="0.0" width="2560" height="1418"/>
<view key="contentView" id="4">
<rect key="frame" x="0.0" y="0.0" width="640" height="496"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<avPlayerView misplaced="YES" controlsStyle="inline" id="s8w-Lv-MOu">
<rect key="frame" x="0.0" y="0.0" width="640" height="496"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
</avPlayerView>
</subviews>
</view>
<connections>
<outlet property="delegate" destination="-2" id="13"/>
</connections>
</window>
</objects>
</document>