Permalink
Browse files

More cleaning and FLV support on Vimeo.

(Somehow Perian's FLV doesn't work when debugging but seems OK otherwise, so I think it's worth doing.)
  • Loading branch information...
1 parent 9f3a48c commit f61aabde5c48d0b53e7aa41b9a345c1ee4da6273 @ssp ssp committed Oct 4, 2009
@@ -46,6 +46,7 @@
6953E43C0F3EDEB50014ECF7 /* MenubarMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 6953E43A0F3EDEB50014ECF7 /* MenubarMenu.xib */; };
69A26D0C0F302C10006648BC /* NSBezierPath-RoundedRectangle.m in Sources */ = {isa = PBXBuildFile; fileRef = 69A26D0B0F302C10006648BC /* NSBezierPath-RoundedRectangle.m */; };
6C2C5A6A1068CE8700A90A54 /* Credits.css in Resources */ = {isa = PBXBuildFile; fileRef = A40485B110629B0E00FDC4E2 /* Credits.css */; };
+ 6C436DAF107830A200A0D525 /* QTKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6C436DAE107830A200A0D525 /* QTKit.framework */; };
6C8EC6F410764F810053587F /* CTFKiller.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C8EC6F310764F810053587F /* CTFKiller.m */; };
6C8EC7051076544D0053587F /* CTFKillerYouTube.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C8EC7041076544D0053587F /* CTFKillerYouTube.m */; };
6C8EC775107671F20053587F /* CTFKillerVideo.m in Sources */ = {isa = PBXBuildFile; fileRef = 6C8EC774107671F20053587F /* CTFKillerVideo.m */; };
@@ -152,6 +153,7 @@
6953E43B0F3EDEB50014ECF7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Plugin/English.lproj/MenubarMenu.xib; sourceTree = "<group>"; };
69A26D0A0F302C10006648BC /* NSBezierPath-RoundedRectangle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = "NSBezierPath-RoundedRectangle.h"; path = "Plugin/NSBezierPath-RoundedRectangle.h"; sourceTree = "<group>"; };
69A26D0B0F302C10006648BC /* NSBezierPath-RoundedRectangle.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "NSBezierPath-RoundedRectangle.m"; path = "Plugin/NSBezierPath-RoundedRectangle.m"; sourceTree = "<group>"; };
+ 6C436DAE107830A200A0D525 /* QTKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QTKit.framework; path = /System/Library/Frameworks/QTKit.framework; sourceTree = "<absolute>"; };
6C8EC6F210764F810053587F /* CTFKiller.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTFKiller.h; path = Plugin/CTFKiller.h; sourceTree = "<group>"; };
6C8EC6F310764F810053587F /* CTFKiller.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CTFKiller.m; path = Plugin/CTFKiller.m; sourceTree = "<group>"; };
6C8EC7031076544D0053587F /* CTFKillerYouTube.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CTFKillerYouTube.h; path = Plugin/CTFKillerYouTube.h; sourceTree = "<group>"; };
@@ -211,6 +213,7 @@
55EB70580E04A8B80016593D /* Cocoa.framework in Frameworks */,
55EB70590E04A8B80016593D /* WebKit.framework in Frameworks */,
0038DE320FC0CE7B007B54E9 /* Carbon.framework in Frameworks */,
+ 6C436DAF107830A200A0D525 /* QTKit.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -291,6 +294,7 @@
0038DE310FC0CE7B007B54E9 /* Carbon.framework */,
55EB70560E04A8B80016593D /* Cocoa.framework */,
55EB70570E04A8B80016593D /* WebKit.framework */,
+ 6C436DAE107830A200A0D525 /* QTKit.framework */,
);
name = Frameworks;
sourceTree = "<group>";
View
@@ -38,27 +38,40 @@
CTFClickToFlashPlugin * plugin;
}
+// Come and go
+
+// Class method returns an instantiated CTFKiller class for the URL/data/plugin passed to it. This is the call to use.
+ (CTFKiller*) killerForURL: (NSURL*) theURL src: (NSString*) theSrc attributes: (NSDictionary*) attributes forPlugin:(CTFClickToFlashPlugin*) thePlugin;
+// Initialiser method doing the basic setup. There should be no need to use this. The +killerForULR:src:attributes:forPlugin class method should handle everything.
- (id) initWithURL: (NSURL*) theURL src:(NSString*) theSrc attributes: (NSDictionary*) attributes forPlugin:(CTFClickToFlashPlugin*) thePlugin;
-// to be implemented by subclasses
+// To be implemented by subclasses
+
+// Return whether this class can handle the Flash for the given URL and other data.
+ (BOOL) canHandleFlashAtURL: (NSURL*) theURL src: (NSString*) theSrc attributes: (NSDictionary*) attributes forPlugin:(CTFClickToFlashPlugin*) thePlugin;
+// Set up the subclass. If further data is needed, fetching it is started here.
- (void) setup;
+// The label displayed in the plug-in. Subclasses can provide their own name here which is read whenever the plug-in view is redrawn.
- (NSString*) badgeLabelText;
+// Called when building the Contextual menu to add a single item at the second position.
- (void) addPrincipalMenuItemToContextualMenu;
+// Called when building the contextual menu to add further items afte the basic Load/Hide Flash items.
- (void) addAdditionalMenuItemsForContextualMenu;
+// Called when the user clicks the CtF view. Replace content here.
- (BOOL) convertToContainer;
-// accessors
+
+// Accessors
- (NSURL *)pageURL;
- (void)setPageURL:(NSURL *)newPageURL;
- (NSString *)srcURLString;
- (void)setSrcURLString:(NSString *)newSrcURLString;
- (NSDictionary *)attributes;
- (void)setAttributes:(NSDictionary *)newAttributes;
-- (NSString*) flashVarWithName: (NSString*) argName;
- (NSDictionary *)flashVars;
- (void)setFlashVars:(NSDictionary *)newFlashVars;
+// get a specific flash variable
+- (NSString*) flashVarWithName: (NSString*) argName;
- (CTFClickToFlashPlugin *)plugin;
- (void)setPlugin:(CTFClickToFlashPlugin *)newPlugin;
View
@@ -32,8 +32,14 @@ of this software and associated documentation files (the "Software"), to deal
@implementation CTFKiller
+#pragma mark -
+#pragma mark Come and go
+
+
+// Class method returns an instantiated CTFKiller class for the URL/data/plugin passed to it. This is the call to use.
+ (CTFKiller*) killerForURL: (NSURL*) theURL src: (NSString*) theSrc attributes: (NSDictionary*) attributes forPlugin:(CTFClickToFlashPlugin*) thePlugin {
CTFKiller * theKiller = nil;
+
NSArray * killerArray = [NSArray arrayWithObjects: NSClassFromString(@"CTFKillerYouTube"), NSClassFromString(@"CTFKillerVimeo"), NSClassFromString(@"CTFKillerSIFR"),nil];
NSEnumerator * myEnum = [killerArray objectEnumerator];
Class killerClass;
@@ -48,11 +54,7 @@ + (CTFKiller*) killerForURL: (NSURL*) theURL src: (NSString*) theSrc attributes:
}
-+ (BOOL) canHandleFlashAtURL: (NSURL*) theURL src: (NSString*) theSrc attributes: (NSDictionary*) attributes forPlugin:(CTFClickToFlashPlugin*) thePlugin {
- return NO;
-}
-
-
+// Initialiser method doing the basic setup. There should be no need to use this. The +killerForULR:src:attributes:forPlugin class method should handle everything.
- (id) initWithURL: (NSURL*) theURL src:(NSString*) theSrc attributes: (NSDictionary*) theAttributes forPlugin:(CTFClickToFlashPlugin*) thePlugin {
self = [super init];
if (self != nil) {
@@ -69,17 +71,6 @@ - (id) initWithURL: (NSURL*) theURL src:(NSString*) theSrc attributes: (NSDictio
return self;
}
-- (void) setup { }
-
-- (NSString*) badgeLabelText {
- return @"CTFKiller";
-}
-
-- (void) addPrincipalMenuItemToContextualMenu { }
-
-- (void) addAdditionalMenuItemsForContextualMenu { }
-
-- (BOOL) convertToContainer { return NO; }
- (void) dealloc {
@@ -95,7 +86,36 @@ - (void) dealloc {
-#pragma mark ACCESSOR METHODS
+#pragma mark -
+#pragma mark Subclass overrides
+
+// Return whether this class can handle the Flash for the given URL and other data.
++ (BOOL) canHandleFlashAtURL: (NSURL*) theURL src: (NSString*) theSrc attributes: (NSDictionary*) attributes forPlugin:(CTFClickToFlashPlugin*) thePlugin {
+ return NO;
+}
+
+// Set up the subclass. If further data is needed, fetching it is started here.
+- (void) setup { }
+
+// The label displayed in the plug-in. Subclasses can provide their own name here which is read whenever the plug-in view is redrawn.
+- (NSString*) badgeLabelText { return nil; }
+
+// Called when building the Contextual menu to add a single item at the second position.
+- (void) addPrincipalMenuItemToContextualMenu { }
+
+// Called when building the contextual menu to add further items afte the basic Load/Hide Flash items.
+- (void) addAdditionalMenuItemsForContextualMenu { }
+
+// Called when the user clicks the CtF view. Replace content here.
+- (BOOL) convertToContainer { return NO; }
+
+
+
+
+
+
+#pragma mark -
+#pragma mark Accessors
- (NSURL *)pageURL
{
@@ -48,12 +48,17 @@ enum CTFKVLookupStatus {
BOOL hasVideoHD;
enum CTFKVLookupStatus lookupStatus;
+ BOOL requiresConversion;
NSSize videoSize;
NSURL * previewURL;
}
-// Subclasses should use setHasVideo and setHasVideoHD to indicate when they have determined movie paths.
+/*
+ Subclasses use setHasVideo and setHasVideoHD to indicate when they have determined movie paths.
+ They set lookupStatus to indicate whether they are still busy doing lookups. Doing this will cause a redraw which can then alter the label text.
+*/
+
// to be implemented by subclasses if they want to
@@ -80,10 +85,9 @@ enum CTFKVLookupStatus {
// Edit or replace the markup that is added for the links beneath the video. The descriptionElement passed to the method already conatins Go to Webpage and Download Video File links.
- (DOMElement *) enhanceVideoDescriptionElement: (DOMElement*) descriptionElement;
-
-//
+// Indicate whether the current web page is the 'canonical' web page for the video. The default implementation compares the videoPageURLString with the current page's URL for that
- (BOOL) isOnVideoPage;
-- (NSString *) cleanURLString: (NSString*) URLString;
+
// Actions
@@ -107,7 +111,9 @@ enum CTFKVLookupStatus {
- (BOOL) useVideo;
- (BOOL) useVideoHD;
- (NSString *) videoURLStringForHD: (BOOL) useHD;
+- (NSString *) cleanURLString: (NSString*) URLString;
- (BOOL) isVideoElementAvailable;
+- (void) finishedLookups;
// Accessors
- (BOOL) autoPlay;
@@ -118,6 +124,8 @@ enum CTFKVLookupStatus {
- (void) setHasVideoHD:(BOOL)newHasVideoHD;
- (enum CTFKVLookupStatus) lookupStatus;
- (void) setLookupStatus: (enum CTFKVLookupStatus) newLookupStatus;
+- (BOOL)requiresConversion;
+- (void)setRequiresConversion:(BOOL)newRequiresConversion;
- (NSURL *) previewURL;
- (void) setPreviewURL: (NSURL *) newPreviewURL;
@@ -46,6 +46,9 @@ - (id) init {
hasVideo = NO;
hasVideoHD = NO;
+ lookupStatus = nothing;
+ requiresConversion = NO;
+
videoSize = NSZeroSize;
[self setPreviewURL:nil];
}
@@ -105,6 +108,8 @@ - (BOOL) isOnVideoPage {
+
+
// Remove http:// and www. from beginning of URL.
- (NSString *) cleanURLString: (NSString*) URLString {
NSString * result = URLString;
@@ -261,10 +266,14 @@ - (void) addAdditionalMenuItemsForContextualMenu;
- (BOOL) convertToContainer {
BOOL result = NO;
- if ([self hasVideo]) {
+ if ([self lookupStatus] == finished && [self hasVideo]) {
[self convertToMP4ContainerUsingHD:nil];
result = YES;
}
+ else if ([self lookupStatus] == inProgress) {
+ [self setRequiresConversion: YES];
+ result = YES;
+ }
return result;
}
@@ -543,7 +552,7 @@ - (DOMElement*) linkContainerElementForURL: (NSString*) URLString {
#pragma mark -
-#pragma mark HELPER
+#pragma mark Helpers
// Determine whether we want to use the video. Returns YES if a video is available and the relevant preference is set.
- (BOOL) useVideo {
@@ -630,8 +639,18 @@ - (BOOL) isVideoElementAvailable
+// Called when asynchronous lookups are finished. This will convert the element if it has been marked for conversion previously but the kind of conversion wasn't clear yet because of the pending lookups.
+- (void) finishedLookups {
+ if ([self requiresConversion]) {
+ [self convertToContainer];
+ }
+}
+
+
+
-#pragma mark ACCESSORS
+#pragma mark -
+#pragma mark Accessors
- (BOOL)autoPlay {
BOOL result = autoPlay;
@@ -670,10 +689,24 @@ - (enum CTFKVLookupStatus) lookupStatus {
- (void) setLookupStatus: (enum CTFKVLookupStatus) newLookupStatus {
lookupStatus = newLookupStatus;
+ if (lookupStatus == finished || lookupStatus == failed) {
+ [self finishedLookups];
+ }
[[self plugin] setNeedsDisplay: YES];
}
+- (BOOL)requiresConversion
+{
+ return requiresConversion;
+}
+
+- (void)setRequiresConversion:(BOOL)newRequiresConversion
+{
+ requiresConversion = newRequiresConversion;
+}
+
+
- (NSURL *)previewURL {
return previewURL;
}
@@ -29,12 +29,21 @@
#import <Cocoa/Cocoa.h>
#import "CTFKillerVideo.h"
+enum CTFVimeoConnectionType {
+ noConnection,
+ XML,
+ HEAD
+};
+
+
@interface CTFKillerVimeo : CTFKillerVideo {
NSString * clipID;
NSString * clipSignature;
NSString * clipExpires;
+ NSString * redirectedURLString;
BOOL clipIsHD;
+ enum CTFVimeoConnectionType currentConnection;
NSMutableData * downloadData;
}
@@ -43,15 +52,17 @@
- (void) getXML;
- (void) finishXMLFetching: (NSURLConnection *) connection;
- (void) finishHEADFetching: (NSURLConnection *) connection;
-- (BOOL) isFetchingXML;
-- (BOOL) isFetchingHEAD;
-
-- (NSString *)clipID;
-- (void)setClipID:(NSString *)newClipID;
-- (NSString *)clipSignature;
-- (void)setClipSignature:(NSString *)newClipSignature;
-- (NSString *)clipExpires;
-- (void)setClipExpires:(NSString *)newClipExpires;
+
+- (NSString *) clipID;
+- (void) setClipID: (NSString *) newClipID;
+- (NSString *) clipSignature;
+- (void) setClipSignature: (NSString *) newClipSignature;
+- (NSString *) clipExpires;
+- (void) setClipExpires: (NSString *) newClipExpires;
+- (NSString *) redirectedURLString;
+- (void) setRedirectedURLString: (NSString *) newRedirectedURLString;
+- (enum CTFVimeoConnectionType) currentConnection;
+- (void) setCurrentConnection: (enum CTFVimeoConnectionType) newConnectionType;
@end
Oops, something went wrong.

0 comments on commit f61aabd

Please sign in to comment.