Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /XspfQT/XspfQTInformationWindowController.m

Parent Directory Parent Directory | Revision Log Revision Log


Revision 374 - (hide annotations) (download)
Sun Mar 4 01:49:53 2012 UTC (12 years, 1 month ago) by masakih
File size: 8089 byte(s)
[Mod] XspfQTInformationWindowControllerにプロパティ

1 masaki 63 //
2     // XspfQTInformationWindowController.m
3     // XspfQT
4     //
5     // Created by Hori,Masaki on 08/09/14.
6     //
7    
8 masakih 312 /*
9 masakih 316 This source code is release under the New BSD License.
10 masakih 374 Copyright (c) 2008-2010,2012, masakih
11 masakih 312 All rights reserved.
12    
13 masakih 316 ソースコード形式かバイナリ形式か、変更するかしないかを問わず、以下の条件を満たす場合に
14     限り、再頒布および使用が許可されます。
15    
16     1, ソースコードを再頒布する場合、上記の著作権表示、本条件一覧、および下記免責条項を含
17     めること。
18     2, バイナリ形式で再頒布する場合、頒布物に付属のドキュメント等の資料に、上記の著作権表
19     示、本条件一覧、および下記免責条項を含めること。
20     3, 書面による特別の許可なしに、本ソフトウェアから派生した製品の宣伝または販売促進に、
21     コントリビューターの名前を使用してはならない。
22     本ソフトウェアは、著作権者およびコントリビューターによって「現状のまま」提供されており、
23     明示黙示を問わず、商業的な使用可能性、および特定の目的に対する適合性に関する暗黙の保証
24     も含め、またそれに限定されない、いかなる保証もありません。著作権者もコントリビューター
25     も、事由のいかんを問わず、 損害発生の原因いかんを問わず、かつ責任の根拠が契約であるか
26     厳格責任であるか(過失その他の)不法行為であるかを問わず、仮にそのような損害が発生する
27     可能性を知らされていたとしても、本ソフトウェアの使用によって発生した(代替品または代用
28     サービスの調達、使用の喪失、データの喪失、利益の喪失、業務の中断も含め、またそれに限定
29     されない)直接損害、間接損害、偶発的な損害、特別損害、懲罰的損害、または結果損害につい
30     て、一切責任を負わないものとします。
31 masakih 312 -------------------------------------------------------------------
32 masakih 374 Copyright (c) 2008-2010,2012, masakih
33 masakih 312 All rights reserved.
34    
35 masakih 316 Redistribution and use in source and binary forms, with or without
36     modification, are permitted provided that the following conditions
37     are met:
38 masakih 312
39 masakih 316 1, Redistributions of source code must retain the above copyright
40     notice, this list of conditions and the following disclaimer.
41     2, Redistributions in binary form must reproduce the above copyright
42     notice, this list of conditions and the following disclaimer in
43     the documentation and/or other materials provided with the
44     distribution.
45     3, The names of its contributors may be used to endorse or promote
46     products derived from this software without specific prior
47     written permission.
48     THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
49     "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
50     LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
51     FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
52     COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
53     INCIDENTAL, SPECIAL,EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
54     BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
55     LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
56     CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
57     LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
58     ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
59     POSSIBILITY OF SUCH DAMAGE.
60 masakih 312 */
61    
62 masaki 63 #import "XspfQTInformationWindowController.h"
63 masaki 72 #import "XspfQTDocument.h"
64 masakih 374 #import "HMXSPFComponent.h"
65 masaki 63
66 masaki 244 static NSString *const XspfQTDocumentQtMovieKeyPath = @"playingMovie";
67     static NSString *const XspfQTCurrentTrackKey = @"currentTrack";
68 masaki 149
69 masakih 374 @interface XspfQTInformationWindowController()
70     @property (readonly) XspfQTDocument *currentDocument;
71     @end
72    
73 masaki 63 @implementation XspfQTInformationWindowController
74     static XspfQTInformationWindowController *sharedInstance = nil;
75    
76     + (XspfQTInformationWindowController *)sharedInstance
77     {
78     @synchronized(self) {
79     if (sharedInstance == nil) {
80 masakih 308 sharedInstance = [[super allocWithZone:NULL] init];
81     }
82 masaki 63 }
83     return sharedInstance;
84     }
85    
86     + (id)allocWithZone:(NSZone *)zone
87     {
88 masakih 308 return [[self sharedInstance] retain];
89 masaki 63 }
90    
91     - (id)copyWithZone:(NSZone *)zone
92     {
93     return self;
94     }
95    
96     - (id)retain
97     {
98     return self;
99     }
100    
101 masaki 303 - (NSUInteger)retainCount
102 masaki 63 {
103     return UINT_MAX; //denotes an object that cannot be released
104     }
105    
106 masakih 367 - (oneway void)release
107 masaki 63 {
108     //do nothing
109     }
110    
111     - (id)autorelease
112     {
113     return self;
114     }
115    
116     #pragma mark-
117     - (id)init
118     {
119     [super initWithWindowNibName:@"XspfQTImformation"];
120     observedDocs = [[NSMutableArray array] retain];
121     return self;
122     }
123    
124 masaki 158 + (NSSet *)keyPathsForValuesAffectingMovieAttributes
125     {
126 masaki 244 return [NSSet setWithObject:XspfQTCurrentTrackKey];
127 masaki 158 }
128     + (NSSet *)keyPathsForValuesAffectingSoundTrackAttributes
129     {
130 masaki 244 return [NSSet setWithObject:XspfQTCurrentTrackKey];
131 masaki 158 }
132     + (NSSet *)keyPathsForValuesAffectingVideoTrackAttributes
133     {
134 masaki 244 return [NSSet setWithObject:XspfQTCurrentTrackKey];
135 masaki 158 }
136 masaki 110 - (void)notify
137     {
138 masaki 244 [self willChangeValueForKey:XspfQTCurrentTrackKey];
139 masaki 133 [self performSelector:@selector(didChangeValueForKey:)
140 masaki 244 withObject:XspfQTCurrentTrackKey
141 masaki 133 afterDelay:0.0];
142 masaki 110 }
143 masaki 241 - (void)currentDocumentDidChangeNotification:(id)notification
144     {
145     [self willChangeValueForKey:@"currentDocument"];
146     [self performSelector:@selector(didChangeValueForKey:)
147     withObject:@"currentDocument"
148     afterDelay:0.0];
149     }
150 masaki 110
151 masaki 63 - (void)windowDidLoad
152     {
153     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
154     [nc addObserver:self
155 masaki 241 selector:@selector(currentDocumentDidChangeNotification:)
156 masaki 63 name:NSWindowDidBecomeMainNotification
157     object:nil];
158     [nc addObserver:self
159 masaki 241 selector:@selector(currentDocumentDidChangeNotification:)
160 masaki 63 name:NSWindowDidResignMainNotification
161     object:nil];
162 masaki 241
163 masaki 63 [nc addObserver:self
164     selector:@selector(notifee:)
165 masaki 133 name:NSWindowDidResizeNotification
166     object:nil];
167    
168    
169 masaki 63 [nc addObserver:self
170     selector:@selector(xspfDocumentWillCloseNotification:)
171 masaki 72 name:XspfQTDocumentWillCloseNotification
172 masaki 63 object:nil];
173    
174     }
175     - (void)dealloc
176     {
177     NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
178     [nc removeObserver:self];
179    
180     [observedDocs release];
181    
182     [super dealloc];
183     }
184    
185 masaki 136 - (void)addObservingDocument:(id)doc
186 masaki 63 {
187 masaki 136 if(!doc) return;
188 masaki 63
189     if(![observedDocs containsObject:doc]) {
190     [doc addObserver:self
191 masaki 244 forKeyPath:XspfQTDocumentQtMovieKeyPath
192 masaki 63 options:0
193     context:NULL];
194     [observedDocs addObject:doc];
195     }
196 masaki 136 }
197 masakih 374 - (XspfQTDocument *)currentDocument
198 masaki 136 {
199     id doc = [[NSDocumentController sharedDocumentController] currentDocument];
200     if(!doc) return nil;
201     [self addObservingDocument:doc];
202 masaki 63
203 masaki 171 return doc;
204     }
205 masakih 374 - (HMXSPFComponent *)currentTrack
206 masaki 171 {
207 masakih 374 return self.currentDocument.trackList.currentTrack;
208 masaki 63 }
209 masakih 374 - (NSDictionary *)movieAttributes
210 masaki 63 {
211 masakih 374 return self.currentDocument.playingMovie.movieAttributes;
212 masaki 63 }
213 masaki 149
214 masakih 374 - (NSDictionary *)trackAttributesByType:(NSString *)type
215 masaki 136 {
216 masakih 374 id movie = self.currentDocument.playingMovie;
217 masaki 149 NSArray *tracks = [movie tracksOfMediaType:type];
218     if(!tracks || [tracks count] == 0) return nil;
219 masaki 136
220 masaki 149 return [[tracks objectAtIndex:0] trackAttributes];
221 masaki 136 }
222 masakih 374 - (NSDictionary *)soundTrackAttributes
223 masaki 149 {
224     return [self trackAttributesByType:QTMediaTypeSound];
225     }
226 masakih 374 - (NSDictionary *)videoTrackAttributes
227 masaki 136 {
228 masaki 149 return [self trackAttributesByType:QTMediaTypeVideo];
229 masaki 136 }
230    
231 masaki 63 - (void)observeValueForKeyPath:(NSString *)keyPath
232     ofObject:(id)object
233     change:(NSDictionary *)change
234     context:(void *)context
235     {
236 masaki 244 if([keyPath isEqualToString:XspfQTDocumentQtMovieKeyPath]) {
237 masaki 110 [self notify];
238 masaki 63 }
239     }
240    
241     - (void)xspfDocumentWillCloseNotification:(id)notification
242     {
243     id doc = [notification object];
244    
245 masaki 110 if(![observedDocs containsObject:doc]) return;
246    
247 masaki 244 [doc removeObserver:self forKeyPath:XspfQTDocumentQtMovieKeyPath];
248 masaki 63 [observedDocs removeObject:doc];
249     [docController setContent:nil];
250 masaki 110 [currentTrackController setContent:nil];
251    
252     [self notify];
253 masaki 63 }
254     - (void)notifee:(id)notification
255     {
256 masaki 110 [self notify];
257 masaki 63 }
258    
259     @end

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26