summaryrefslogtreecommitdiffstats
path: root/macosx/HBAVPlayer.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/HBAVPlayer.m
parentc90c56d457427ee310f356bd140f8afd4fb446f0 (diff)
MacGui: fallback to QTKit if a preview is not playable with AVFoundation.
Diffstat (limited to 'macosx/HBAVPlayer.m')
-rw-r--r--macosx/HBAVPlayer.m21
1 files changed, 6 insertions, 15 deletions
diff --git a/macosx/HBAVPlayer.m b/macosx/HBAVPlayer.m
index 748aa39f1..892cf17f9 100644
--- a/macosx/HBAVPlayer.m
+++ b/macosx/HBAVPlayer.m
@@ -40,7 +40,8 @@ typedef void (^HBPlayableObverser)(void);
@property (nonatomic, strong) NSMutableSet<HBAVPlayerRateObserver *> *rateObservers;
@property (nonatomic, strong) NSMutableSet<HBPlayableObverser> *playableObservers;
-@property (nonatomic, readwrite) BOOL playable;
+@property (nonatomic, readwrite, getter=isPlayable) BOOL playable;
+@property (nonatomic, readwrite, getter=isLoaded) BOOL loaded;
@end
@@ -53,20 +54,9 @@ typedef void (^HBPlayableObverser)(void);
if (self)
{
_movie = [AVAsset assetWithURL:url];;
-
- if (!_movie)
- {
- return nil;
- }
-
_player = [[AVPlayer alloc] init];
_layer = [CALayer layer];
- if (!_layer || !_player)
- {
- return nil;
- }
-
_rateObservers = [NSMutableSet set];
_playableObservers = [NSMutableSet set];
@@ -80,6 +70,7 @@ typedef void (^HBPlayableObverser)(void);
// Because we want to access our AVPlayer in our ensuing set-up, we must dispatch our handler to the main queue.
dispatch_async(dispatch_get_main_queue(), ^(void) {
[self _setUpPlaybackOfAsset:_movie withKeys:assetKeysToLoadAndTest];
+ self.loaded = YES;
});
}];
@@ -128,9 +119,9 @@ typedef void (^HBPlayableObverser)(void);
}
}
-- (void)setPlayable:(BOOL)playable
+- (void)setLoaded:(BOOL)loaded
{
- _playable = playable;
+ _loaded = loaded;
for (HBPlayableObverser block in self.playableObservers)
{
@@ -290,7 +281,7 @@ typedef void (^HBPlayableObverser)(void);
- (void)loadPlayableValueAsynchronouslyWithCompletionHandler:(nullable void (^)(void))handler;
{
- if (self.playable)
+ if (self.isLoaded)
{
handler();
}