summaryrefslogtreecommitdiffstats
path: root/macosx/HBQTKitPlayer.m
diff options
context:
space:
mode:
authorDamiano Galassi <[email protected]>2016-05-19 13:44:52 +0200
committerDamiano Galassi <[email protected]>2016-05-19 13:44:52 +0200
commit26b48313574002f7722d03e13d713d4ca7b55aca (patch)
tree3e592c5d094b2dbecce52816c43919c9d8619986 /macosx/HBQTKitPlayer.m
parentc90c56d457427ee310f356bd140f8afd4fb446f0 (diff)
MacGui: fallback to QTKit if a preview is not playable with AVFoundation.
Diffstat (limited to 'macosx/HBQTKitPlayer.m')
-rw-r--r--macosx/HBQTKitPlayer.m61
1 files changed, 27 insertions, 34 deletions
diff --git a/macosx/HBQTKitPlayer.m b/macosx/HBQTKitPlayer.m
index b0b608e3a..e44413f55 100644
--- a/macosx/HBQTKitPlayer.m
+++ b/macosx/HBQTKitPlayer.m
@@ -57,6 +57,7 @@ typedef void (^HBPlayableObverser)(void);
@property (nonatomic, strong) NSTimer *timer;
@property (nonatomic, readwrite, getter=isPlayable) BOOL playable;
+@property (nonatomic, readwrite, getter=isLoaded) BOOL loaded;
@property (nonatomic, strong) NSMutableSet<HBQTKitPlayerPeriodicObserver *> *periodicObservers;
@property (nonatomic, strong) NSMutableSet<HBQTKitPlayerRateObserver *> *rateObservers;
@@ -78,38 +79,41 @@ typedef void (^HBPlayableObverser)(void);
QTMovieAskUnresolvedDataRefsAttribute: @NO,
QTMovieOpenForPlaybackAttribute: @YES,
QTMovieIsSteppableAttribute: @YES,
- QTMovieOpenAsyncRequiredAttribute: @YES,
+ QTMovieOpenAsyncRequiredAttribute: @NO,
+ QTMovieOpenAsyncOKAttribute: @NO,
QTMovieApertureModeAttribute: QTMovieApertureModeClean };
_movie = [[QTMovie alloc] initWithAttributes:attributes error:&outError];
- if (!_movie)
+ if (_movie)
{
- return nil;
- }
-
- _movie.delegate = self;
-
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_movieRateDidChange:)
- name:QTMovieRateDidChangeNotification
- object:_movie];
+ _movie.delegate = self;
- [[NSNotificationCenter defaultCenter] addObserver:self
- selector:@selector(_loadStateChanged:)
- name:QTMovieLoadStateDidChangeNotification
- object:_movie];
+ [[NSNotificationCenter defaultCenter] addObserver:self
+ selector:@selector(_movieRateDidChange:)
+ name:QTMovieRateDidChangeNotification
+ object:_movie];
- _layer = [QTMovieLayer layerWithMovie:_movie];
-
- if (!_layer)
- {
- return nil;
+ _layer = [QTMovieLayer layerWithMovie:_movie];
}
_periodicObservers = [NSMutableSet set];
_rateObservers = [NSMutableSet set];
_playableObservers = [NSMutableSet set];
+
+ // Can't open things async
+ // because of 23414 QTKit bugs.
+ if (_movie && _layer)
+ {
+ self.playable = YES;
+ [self _enableSubtitles];
+ }
+ else
+ {
+ self.playable = NO;
+ }
+
+ self.loaded = YES;
}
return self;
@@ -121,9 +125,9 @@ typedef void (^HBPlayableObverser)(void);
[self _stopMovieTimer];
}
-- (void)setPlayable:(BOOL)playable
+- (void)setLoaded:(BOOL)loaded
{
- _playable = playable;
+ _loaded = loaded;
for (HBPlayableObverser block in self.playableObservers)
{
@@ -132,17 +136,6 @@ typedef void (^HBPlayableObverser)(void);
[self.playableObservers removeAllObjects];
}
-- (void)_loadStateChanged:(NSNotification *)notification
-{
- int loadState = [[self.movie attributeForKey:QTMovieLoadStateAttribute] intValue];
-
- if (loadState >= QTMovieLoadStateLoaded)
- {
- [self _enableSubtitles];
- self.playable = YES;
- }
-}
-
- (void)_movieRateDidChange:(NSNotification *)notification
{
for (HBQTKitPlayerRateObserver *observer in self.rateObservers)
@@ -325,7 +318,7 @@ typedef void (^HBPlayableObverser)(void);
- (void)loadPlayableValueAsynchronouslyWithCompletionHandler:(nullable void (^)(void))handler;
{
- if (self.playable)
+ if (self.isLoaded)
{
handler();
}