Commit a6fa0a68 authored by Tobias's avatar Tobias Committed by Felix Paul Kühne

improve now playing play pause button state handing

parent 7bea7864
......@@ -670,6 +670,7 @@
responseDict = [self nowPlayingResponseDict];
} else if ([userInfo[@"name"] isEqualToString:@"playpause"]) {
[_movieViewController playPause];
responseDict = @{@"playing": @(_movieViewController.isPlaying)};
} else if ([userInfo[@"name"] isEqualToString:@"skipForward"]) {
[_movieViewController forward:nil];
} else if ([userInfo[@"name"] isEqualToString:@"skipBackward"]) {
......
......@@ -84,6 +84,8 @@
@property (nonatomic, strong) IBOutlet UILabel *trackNameLabel;
@property (nonatomic, strong) IBOutlet UIImageView *artworkImageView;
@property (nonatomic, readonly, getter=isPlaying) BOOL playing;
- (IBAction)closePlayback:(id)sender;
- (IBAction)positionSliderAction:(id)sender;
......
......@@ -847,6 +847,12 @@ currentMediaHasTrackToChooseFrom:(BOOL)currentMediaHasTrackToChooseFrom
self.videoFilterButton.hidden = audioOnly;
}
- (BOOL)isPlaying
{
return [VLCPlaybackController sharedInstance].isPlaying;
}
- (IBAction)playPause
{
LOCKCHECK;
......
......@@ -25,21 +25,13 @@
}
@property (nonatomic, copy) NSString *titleString;
@property (nonatomic, copy) NSNumber *playBackDurationNumber;
@property (nonatomic) BOOL isPlaying;
@property (nonatomic, getter=isPlaying) BOOL playing;
@property (nonatomic) NSTimer *updateTimer;
@property (nonatomic, weak) MLFile *currentFile;
@end
@implementation VLCNowPlayingInterfaceController
- (instancetype)init
{
self = [super init];
if (self) {
_isPlaying = YES;
}
return self;
}
- (void)awakeWithContext:(id)context {
[super awakeWithContext:context];
......@@ -49,6 +41,8 @@
[self setTitle:NSLocalizedString(@"PLAYING", nil)];
[self setPlaying:YES];
[self requestNowPlayingInfo];
[[VLCNotificationRelay sharedRelay] addRelayRemoteName:@"org.videolan.ios-app.nowPlayingInfoUpdate" toLocalName:@"nowPlayingInfoUpdate"];
}
......@@ -106,8 +100,14 @@
self.playBackDurationNumber = duration;
/* do not block */
[self performSelectorInBackground:@selector(loadThumbnailForFile:) withObject:file];
NSNumber *rate = nowPlayingInfo[MPNowPlayingInfoPropertyPlaybackRate];
self.playing = rate.floatValue > 0.0;
if ([self.currentFile isEqual:file]) {
self.currentFile = file;
/* do not block */
[self performSelectorInBackground:@selector(loadThumbnailForFile:) withObject:file];
}
}
- (void)loadThumbnailForFile:(MLFile *)file
......@@ -118,8 +118,13 @@
}
- (IBAction)playPausePressed {
self.isPlaying = !self.isPlaying;
[WKInterfaceController openParentApplication:@{@"name": @"playpause"} reply:^(NSDictionary *replyInfo, NSError *error) {
NSNumber *playing = replyInfo[@"playing"];
if ([playing isKindOfClass:[NSNumber class]]) {
self.playing = playing.boolValue;
} else {
self.playing = !self.playing;
}
if (error)
NSLog(@"playpause failed with reply %@ error: %@",replyInfo,error);
}];
......@@ -140,10 +145,11 @@
}
- (void)setIsPlaying:(BOOL)isPlaying {
[self.playPauseButton setBackgroundImageNamed:isPlaying? @"pause":@"play"];
_isPlaying = isPlaying;
- (void)setPlaying:(BOOL)playing {
if (_playing != playing) {
[self.playPauseButton setBackgroundImageNamed:playing? @"pause":@"play"];
_playing = playing;
}
}
- (void)setTitleString:(NSString *)titleString {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment