-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathAudioImageView.m
40 lines (34 loc) · 1.27 KB
/
AudioImageView.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// AudioImageView.m
// Tumblg
//
// Created by orta on 10/08/2008.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//
#import "AudioImageView.h"
@implementation AudioImageView
- (NSDragOperation)draggingEntered:(id <NSDraggingInfo>)sender
{
if ((NSDragOperationGeneric & [sender draggingSourceOperationMask]) == NSDragOperationGeneric){
[self setNeedsDisplay:YES];
NSPasteboard *pboard = [sender draggingPasteboard];
NSString *fileName = [[pboard propertyListForType:NSFilenamesPboardType] objectAtIndex: 0];
NSString *extension = [fileName pathExtension];
if (([extension caseInsensitiveCompare:@"mp3"] == NSOrderedSame) ||
([extension caseInsensitiveCompare:@"aiff"] == NSOrderedSame) ||
([extension caseInsensitiveCompare:@"aac"] == NSOrderedSame) ||
([extension caseInsensitiveCompare:@"wav"] == NSOrderedSame) ||
([extension caseInsensitiveCompare:@"m4a"] == NSOrderedSame)){
return NSDragOperationCopy;
}
}
return NSDragOperationNone;
}
- (BOOL)performDragOperation:(id <NSDraggingInfo>)sender
{
NSPasteboard *pboard = [sender draggingPasteboard];
NSString *fileName = [[pboard propertyListForType:NSFilenamesPboardType] objectAtIndex: 0];
[audioController setSource:fileName];
return YES;
}
@end