From b2760f9f54b58e8342a3a2586d6345c1d2bc535c Mon Sep 17 00:00:00 2001 From: wutschel Date: Fri, 29 Nov 2024 10:36:19 +0100 Subject: [PATCH 01/13] Reimplement starting playback in ShowInfoVC Avoid to use Playlist.Clear, Playlist.Add and starting to play a playlist index. Instead, directly call Player.Open with the item, which then allows to resume the position via API. As Player.Open anyway will clear and update the playlist, this is a much simpler and more robust way to start or resume the playback. --- XBMC Remote/ShowInfoViewController.m | 112 ++++++--------------------- 1 file changed, 23 insertions(+), 89 deletions(-) diff --git a/XBMC Remote/ShowInfoViewController.m b/XBMC Remote/ShowInfoViewController.m index 0aba1ee87..935938ef3 100644 --- a/XBMC Remote/ShowInfoViewController.m +++ b/XBMC Remote/ShowInfoViewController.m @@ -410,14 +410,14 @@ - (void)actionSheetHandler:(NSString*)actiontitle { [self addQueueAfterCurrent:NO]; } else if ([actiontitle isEqualToString:LOCALIZED_STR(@"Play")]) { - [self addPlayback:0.0]; + [self startPlayback:NO]; } else if ([actiontitle isEqualToString:LOCALIZED_STR(@"Record")] || [actiontitle isEqualToString:LOCALIZED_STR(@"Stop Recording")]) { [self recordChannel]; } else if ([actiontitle rangeOfString:LOCALIZED_STR(@"Resume from")].location != NSNotFound) { - [self resumePlayback]; + [self startPlayback:YES]; } else if ([actiontitle isEqualToString:LOCALIZED_STR(@"Play Trailer")]) { NSDictionary *itemParams = @{ @@ -1720,44 +1720,7 @@ - (void)addQueueAfterCurrent:(BOOL)afterCurrent { } } -- (void)resumePlayback { - NSDictionary *item = self.detailItem; - if ([item[@"family"] isEqualToString:@"broadcastid"]) { - NSDictionary *itemParams = @{ - @"item": [NSDictionary dictionaryWithObjectsAndKeys: item[@"pvrExtraInfo"][@"channelid"], @"channelid", nil], - }; - [self openFile:itemParams]; - } - else { - self.navigationItem.rightBarButtonItem.enabled = NO; - [activityIndicatorView startAnimating]; - NSString *key = item[@"family"]; - id value = item[key]; - if (!value || !key) { - [activityIndicatorView stopAnimating]; - return; - } - NSDictionary *params = @{ - @"item": @{ - key: value, - }, - @"options": @{ - @"resume": @YES, - }, - }; - [[Utilities getJsonRPC] callMethod:@"Player.Open" withParameters:params onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { - if (error == nil && methodError == nil) { - [[NSNotificationCenter defaultCenter] postNotificationName: @"XBMCPlaylistHasChanged" object: nil]; - [self showNowPlaying]; - [Utilities checkForReviewRequest]; - } - [activityIndicatorView stopAnimating]; - self.navigationItem.rightBarButtonItem.enabled = YES; - }]; - } -} - -- (void)addPlayback:(float)resumePointLocal { +- (void)startPlayback:(BOOL)resume { NSDictionary *item = self.detailItem; if ([item[@"family"] isEqualToString:@"broadcastid"]) { NSDictionary *itemParams = @{ @@ -1768,60 +1731,31 @@ - (void)addPlayback:(float)resumePointLocal { else { self.navigationItem.rightBarButtonItem.enabled = NO; [activityIndicatorView startAnimating]; - int playlistid = [item[@"playlistid"] intValue]; - [[Utilities getJsonRPC] callMethod:@"Playlist.Clear" withParameters:@{@"playlistid": @(playlistid)} onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { + NSString *key = item[@"family"]; + id value = item[key]; + if (!value || !key) { + [activityIndicatorView stopAnimating]; + return; + } + NSDictionary *params = @{ + @"item": @{ + key: value, + }, + @"options": @{ + @"resume": @(resume), + }, + }; + [[Utilities getJsonRPC] callMethod:@"Player.Open" withParameters:params onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { if (error == nil && methodError == nil) { - NSString *key = item[@"family"]; - id value = item[key]; - // If Playlist.Insert and Playlist.Add for recordingid is not supported, use file path. - if (![VersionCheck hasRecordingIdPlaylistSupport] && [item[@"family"] isEqualToString:@"recordingid"]) { - key = @"file"; - value = item[@"file"]; - } - if (!value || !key) { - [activityIndicatorView stopAnimating]; - return; - } - NSDictionary *params = @{ - @"playlistid": @(playlistid), - @"item": @{key: value}, - }; - [[Utilities getJsonRPC] callMethod:@"Playlist.Add" withParameters:params onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { - if (error == nil && methodError == nil) { - [[NSNotificationCenter defaultCenter] postNotificationName: @"XBMCPlaylistHasChanged" object: nil]; - NSDictionary *params = @{ - @"item": @{ - @"playlistid": @(playlistid), - @"position": @(0), - }, - }; - [[Utilities getJsonRPC] callMethod:@"Player.Open" withParameters:params onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { - if (error == nil && methodError == nil) { - [[NSNotificationCenter defaultCenter] postNotificationName: @"XBMCPlaylistHasChanged" object: nil]; - [activityIndicatorView stopAnimating]; - [self showNowPlaying]; - [Utilities checkForReviewRequest]; - if (resumePointLocal) { - [NSThread sleepForTimeInterval:1.0]; - [self SimpleAction:@"Player.Seek" params:[Utilities buildPlayerSeekPercentageParams:playlistid percentage:resumePointLocal]]; - } - } - else { - [activityIndicatorView stopAnimating]; - self.navigationItem.rightBarButtonItem.enabled = YES; - } - }]; - } - else { - [activityIndicatorView stopAnimating]; - self.navigationItem.rightBarButtonItem.enabled = YES; - } - }]; + [[NSNotificationCenter defaultCenter] postNotificationName: @"XBMCPlaylistHasChanged" object: nil]; + [activityIndicatorView stopAnimating]; + [self showNowPlaying]; + [Utilities checkForReviewRequest]; } else { [activityIndicatorView stopAnimating]; - self.navigationItem.rightBarButtonItem.enabled = YES; } + self.navigationItem.rightBarButtonItem.enabled = YES; }]; } } From 66e5fb0d95272dd7cb1aa2998723417a1e6dd42f Mon Sep 17 00:00:00 2001 From: wutschel Date: Sun, 22 Dec 2024 11:00:10 +0100 Subject: [PATCH 02/13] Remove obsolete check from startSlideshow Check support of Playlist.Insert/.Add for recordings is not required when starting a slideshow, as this does not use any Playlist API anymore. --- XBMC Remote/DetailViewController.m | 5 ----- 1 file changed, 5 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index eaf695ea5..76dd8c99c 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4397,11 +4397,6 @@ - (void)startSlideshow:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath { if ([item[@"filetype"] isEqualToString:@"directory"]) { key = @"directory"; } - // If Playlist.Insert and Playlist.Add for recordingid is not supported, use file path. - else if (![VersionCheck hasRecordingIdPlaylistSupport] && [mainFields[@"row8"] isEqualToString:@"recordingid"]) { - key = @"file"; - value = item[@"file"]; - } if (!value || !key) { [cellActivityIndicator stopAnimating]; return; From e8254e2c8ca29c1eb3ce1f21f8d8b5f5302ecde0 Mon Sep 17 00:00:00 2001 From: wutschel Date: Sun, 22 Dec 2024 11:20:05 +0100 Subject: [PATCH 03/13] Remove unused parameter from buildPlaylistItems --- XBMC Remote/DetailViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index 76dd8c99c..874fcddba 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4197,7 +4197,7 @@ - (void)addQueue:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath afterCurr forceMusicAlbumMode = NO; } int playlistid = [mainFields[@"playlistid"] intValue]; - id playlistItems = [self buildPlaylistItems:playlistid item:item key:mainFields[@"row9"]]; + id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row9"]]; if (!playlistItems) { [cellActivityIndicator stopAnimating]; return; @@ -4345,7 +4345,7 @@ - (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using: } [[Utilities getJsonRPC] callMethod:@"Playlist.Clear" withParameters:@{@"playlistid": @(playlistid)} onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { if (error == nil && methodError == nil) { - id playlistItems = [self buildPlaylistItems:playlistid item:item key:mainFields[@"row8"]]; + id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row8"]]; if (!playlistItems) { [cellActivityIndicator stopAnimating]; return; @@ -4419,7 +4419,7 @@ - (void)startSlideshow:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath { [self playerOpen:playbackParams index:nil indicator:cellActivityIndicator]; } -- (id)buildPlaylistItems:(int)playlistid item:(NSDictionary*)item key:(id)key { +- (id)buildPlaylistItems:(NSDictionary*)item key:(id)key { id value = item[key]; if ([item[@"filetype"] isEqualToString:@"directory"]) { key = @"directory"; From 097fe54e99098b9e747d9a4eb47cdc1f8f3caa1d Mon Sep 17 00:00:00 2001 From: wutschel Date: Sun, 22 Dec 2024 11:43:53 +0100 Subject: [PATCH 04/13] Playback will start from pos = 0 in this case --- XBMC Remote/DetailViewController.m | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index 874fcddba..a7fc18cad 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -1500,7 +1500,7 @@ - (void)viewChild:(NSIndexPath*)indexPath item:(NSDictionary*)item displayPoint: [self showActionSheet:indexPath sheetActions:sheetActions item:item rectOriginX:rectOriginX rectOriginY:rectOriginY]; } else { - [self addPlayback:item indexPath:indexPath position:indexPath.row shuffle:NO]; + [self addPlayback:item indexPath:indexPath position:0 shuffle:NO]; } return; } @@ -1619,7 +1619,7 @@ - (void)didSelectItemAtIndexPath:(NSIndexPath*)indexPath item:(NSDictionary*)ite [self showActionSheet:indexPath sheetActions:sheetActions item:item rectOriginX:rectOriginX rectOriginY:rectOriginY]; } else { - [self addPlayback:item indexPath:indexPath position:indexPath.row shuffle:NO]; + [self addPlayback:item indexPath:indexPath position:0 shuffle:NO]; } } } @@ -3243,7 +3243,7 @@ - (void)showActionSheet:(NSIndexPath*)indexPath sheetActions:(NSArray*)sheetActi [self showActionSheetOptions:title options:sheetActions recording:isRecording origin:sheetOrigin fromcontroller:showFromCtrl fromview:self.view]; } else if (indexPath != nil) { // No actions found, revert back to standard play action - [self addPlayback:item indexPath:indexPath position:indexPath.row shuffle:NO]; + [self addPlayback:item indexPath:indexPath position:0 shuffle:NO]; forceMusicAlbumMode = NO; } } From 5baaad7ddc0cddaa162338fb2a65af71f700d9be Mon Sep 17 00:00:00 2001 From: wutschel Date: Sun, 22 Dec 2024 11:32:31 +0100 Subject: [PATCH 05/13] Rework starting playback This is now done purely by calling Player.Open, and not by updating a playlist and playing from the desired playlist index. --- XBMC Remote/DetailViewController.m | 78 +++++++++--------------------- 1 file changed, 24 insertions(+), 54 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index a7fc18cad..fa229b510 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4300,7 +4300,6 @@ - (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using: } UIActivityIndicatorView *cellActivityIndicator = [self getCellActivityIndicator:indexPath]; [cellActivityIndicator startAnimating]; - int playlistid = [mainFields[@"playlistid"] intValue]; if ([mainFields[@"row8"] isEqualToString:@"channelid"] || [mainFields[@"row8"] isEqualToString:@"broadcastid"]) { NSNumber *channelid = item[mainFields[@"row8"]]; @@ -4319,7 +4318,7 @@ - (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using: [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; } else if (playername.length) { - NSString *key = mainFields[@"row8"]; + NSString *key = mainFields[@"row9"]; id value = item[key]; if ([item[@"filetype"] isEqualToString:@"directory"]) { key = @"directory"; @@ -4337,49 +4336,32 @@ - (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using: [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; } else { - id optionsParam = nil; - id optionsValue = nil; + id optionsKey; + id optionsValue; if (AppDelegate.instance.serverVersion > 11) { - optionsParam = @"options"; + optionsKey = @"options"; optionsValue = @{@"shuffled": @(shuffled)}; } - [[Utilities getJsonRPC] callMethod:@"Playlist.Clear" withParameters:@{@"playlistid": @(playlistid)} onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { - if (error == nil && methodError == nil) { - id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row8"]]; - if (!playlistItems) { - [cellActivityIndicator stopAnimating]; - return; - } - NSDictionary *playlistParams = @{ - @"playlistid": @(playlistid), - @"item": playlistItems, - }; - NSDictionary *playbackParams = [NSDictionary dictionaryWithObjectsAndKeys: - @{@"playlistid": @(playlistid), @"position": @(pos)}, @"item", - optionsValue, optionsParam, - nil]; - if (shuffled && AppDelegate.instance.serverVersion > 11) { - [[Utilities getJsonRPC] - callMethod:@"Player.SetPartymode" - withParameters:@{@"playerid": @(0), @"partymode": @NO} - onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *internalError) { - [self playlistAndPlay:playlistParams - playbackParams:playbackParams - indexPath:indexPath - indicator:cellActivityIndicator]; - }]; - } - else { - [self playlistAndPlay:playlistParams - playbackParams:playbackParams - indexPath:indexPath - indicator:cellActivityIndicator]; - } - } - else { - [cellActivityIndicator stopAnimating]; - } - }]; + id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row9"]]; + if (!playlistItems) { + [cellActivityIndicator stopAnimating]; + return; + } + NSDictionary *playbackParams = [NSDictionary dictionaryWithObjectsAndKeys: + playlistItems, @"item", + optionsValue, optionsKey, + nil]; + if (shuffled && AppDelegate.instance.serverVersion > 11) { + [[Utilities getJsonRPC] + callMethod:@"Player.SetPartymode" + withParameters:@{@"playerid": @(0), @"partymode": @NO} + onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *internalError) { + [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; + }]; + } + else { + [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; + } } } @@ -4462,18 +4444,6 @@ - (id)buildPlaylistItems:(NSDictionary*)item key:(id)key { return playlistItems; } -- (void)playlistAndPlay:(NSDictionary*)playlistParams playbackParams:(NSDictionary*)playbackParams indexPath:(NSIndexPath*)indexPath indicator:(UIActivityIndicatorView*)cellActivityIndicator { - [[Utilities getJsonRPC] callMethod:@"Playlist.Add" withParameters:playlistParams onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { - if (error == nil && methodError == nil) { - [[NSNotificationCenter defaultCenter] postNotificationName: @"XBMCPlaylistHasChanged" object: nil]; - [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; - } - else { - [cellActivityIndicator stopAnimating]; - } - }]; -} - - (void)SimpleAction:(NSString*)action params:(NSDictionary*)parameters success:(NSString*)successMessage failure:(NSString*)failureMessage { [[Utilities getJsonRPC] callMethod:action withParameters:parameters onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { if (error == nil && methodError == nil) { From ea19c11b2785cb5cdba23817cfdb74628f4f7851 Mon Sep 17 00:00:00 2001 From: wutschel Date: Sun, 22 Dec 2024 15:44:59 +0100 Subject: [PATCH 06/13] Rename startPlayback and remove obsolete parameter --- XBMC Remote/DetailViewController.m | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index fa229b510..4364f4744 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -1500,7 +1500,7 @@ - (void)viewChild:(NSIndexPath*)indexPath item:(NSDictionary*)item displayPoint: [self showActionSheet:indexPath sheetActions:sheetActions item:item rectOriginX:rectOriginX rectOriginY:rectOriginY]; } else { - [self addPlayback:item indexPath:indexPath position:0 shuffle:NO]; + [self startPlayback:item indexPath:indexPath shuffle:NO]; } return; } @@ -1619,7 +1619,7 @@ - (void)didSelectItemAtIndexPath:(NSIndexPath*)indexPath item:(NSDictionary*)ite [self showActionSheet:indexPath sheetActions:sheetActions item:item rectOriginX:rectOriginX rectOriginY:rectOriginY]; } else { - [self addPlayback:item indexPath:indexPath position:0 shuffle:NO]; + [self startPlayback:item indexPath:indexPath shuffle:NO]; } } } @@ -3243,7 +3243,7 @@ - (void)showActionSheet:(NSIndexPath*)indexPath sheetActions:(NSArray*)sheetActi [self showActionSheetOptions:title options:sheetActions recording:isRecording origin:sheetOrigin fromcontroller:showFromCtrl fromview:self.view]; } else if (indexPath != nil) { // No actions found, revert back to standard play action - [self addPlayback:item indexPath:indexPath position:0 shuffle:NO]; + [self startPlayback:item indexPath:indexPath shuffle:NO]; forceMusicAlbumMode = NO; } } @@ -3523,8 +3523,7 @@ - (void)actionSheetHandler:(NSString*)actiontitle origin:(CGPoint)origin fromcon [self startSlideshow:item indexPath:selectedIndexPath]; } else { - NSInteger playFromPosition = albumView ? selectedIndexPath.row : 0; - [self addPlayback:item indexPath:selectedIndexPath position:playFromPosition shuffle:NO]; + [self startPlayback:item indexPath:selectedIndexPath shuffle:NO]; } } else if ([actiontitle isEqualToString:LOCALIZED_STR(@"Play using...")]) { @@ -3543,7 +3542,7 @@ - (void)actionSheetHandler:(NSString*)actiontitle origin:(CGPoint)origin fromcon for (NSString *actiontitle in sheetActions) { UIAlertAction *action = [UIAlertAction actionWithTitle:actiontitle style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { - [self addPlayback:item indexPath:selectedIndexPath using:actiontitle shuffle:NO]; + [self startPlayback:item indexPath:selectedIndexPath using:actiontitle shuffle:NO]; }]; [actionView addAction:action]; } @@ -3567,7 +3566,7 @@ - (void)actionSheetHandler:(NSString*)actiontitle origin:(CGPoint)origin fromcon [self deleteTimer:item indexPath:selectedIndexPath]; } else if ([actiontitle isEqualToString:LOCALIZED_STR(@"Play in shuffle mode")]) { - [self addPlayback:item indexPath:selectedIndexPath position:0 shuffle:YES]; + [self startPlayback:item indexPath:selectedIndexPath shuffle:YES]; } else if ([actiontitle isEqualToString:LOCALIZED_STR(@"Queue")]) { [self addQueue:item indexPath:selectedIndexPath]; @@ -4280,15 +4279,11 @@ - (void)playerOpen:(NSDictionary*)params index:(NSIndexPath*)indexPath indicator }]; } -- (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using:(NSString*)playername shuffle:(BOOL)shuffled { - [self addPlayback:item indexPath:indexPath using:playername position:0 shuffle:shuffled]; +- (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath shuffle:(BOOL)shuffled { + [self startPlayback:item indexPath:indexPath using:nil shuffle:shuffled]; } -- (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath position:(NSInteger)pos shuffle:(BOOL)shuffled { - [self addPlayback:item indexPath:indexPath using:nil position:pos shuffle:shuffled]; -} - -- (void)addPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using:(NSString*)playername position:(NSInteger)pos shuffle:(BOOL)shuffled { +- (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath using:(NSString*)playername shuffle:(BOOL)shuffled { mainMenu *menuItem = [self getMainMenu:item]; NSDictionary *mainFields = menuItem.mainFields[choosedTab]; if (forceMusicAlbumMode) { From db54207c6f89ed5faa12c8bf7923a6d8446962bd Mon Sep 17 00:00:00 2001 From: wutschel Date: Mon, 23 Dec 2024 08:45:50 +0100 Subject: [PATCH 07/13] Special handling for video addons can be removed Video addons can now be processed by the default logic, as also Player.Open is used. --- XBMC Remote/DetailViewController.m | 6 ------ 1 file changed, 6 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index 4364f4744..d27a8dc3b 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4306,12 +4306,6 @@ - (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath usin }; [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; } - else if ([mainFields[@"row7"] isEqualToString:@"plugin"]) { - NSDictionary *itemParams = @{ - @"item": [NSDictionary dictionaryWithObjectsAndKeys: item[@"file"], @"file", nil], - }; - [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; - } else if (playername.length) { NSString *key = mainFields[@"row9"]; id value = item[key]; From 4ffe5b9e1058a8c22449359a613919548965c445 Mon Sep 17 00:00:00 2001 From: wutschel Date: Mon, 23 Dec 2024 09:40:34 +0100 Subject: [PATCH 08/13] Special handling for "Play using..." can be removed "Play using..." can now be processed by the default logic, as also Player.Open is used. --- XBMC Remote/DetailViewController.m | 23 ++++------------------- 1 file changed, 4 insertions(+), 19 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index d27a8dc3b..1024b913b 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4306,30 +4306,15 @@ - (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath usin }; [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; } - else if (playername.length) { - NSString *key = mainFields[@"row9"]; - id value = item[key]; - if ([item[@"filetype"] isEqualToString:@"directory"]) { - key = @"directory"; - } - if (!value || !key) { - return; - } - NSDictionary *itemParams = @{ - @"item": @{key: value}, - @"options": @{ - @"playername": playername, - @"shuffled": @(shuffled), - }, - }; - [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; - } else { id optionsKey; id optionsValue; if (AppDelegate.instance.serverVersion > 11) { optionsKey = @"options"; - optionsValue = @{@"shuffled": @(shuffled)}; + optionsValue = [NSDictionary dictionaryWithObjectsAndKeys: + @(shuffled), @"shuffled", + playername, @"playername", + nil]; } id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row9"]]; if (!playlistItems) { From 71c105ccd4f37fc3da43fb047411fd506a99e29d Mon Sep 17 00:00:00 2001 From: wutschel Date: Mon, 23 Dec 2024 08:56:31 +0100 Subject: [PATCH 09/13] Prepare Live TV and Radio for using common key in startPlayback --- XBMC Remote/AppDelegate.m | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/XBMC Remote/AppDelegate.m b/XBMC Remote/AppDelegate.m index 64ef22ceb..1e54b0a92 100644 --- a/XBMC Remote/AppDelegate.m +++ b/XBMC Remote/AppDelegate.m @@ -4494,9 +4494,10 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N @"row6": @"channelid", @"playlistid": @PLAYERID_VIDEO, @"row8": @"channelid", - @"row9": @"isrecording", - @"row10": @"channelnumber", - @"row11": @"type", + @"row9": @"channelid", + @"row10": @"isrecording", + @"row11": @"channelnumber", + @"row12": @"type", }, @{ @@ -4673,13 +4674,14 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N @"row6": @"broadcastid", @"playlistid": @PLAYERID_VIDEO, @"row8": @"broadcastid", - @"row9": @"plotoutline", + @"row9": @"broadcastid", @"row10": @"starttime", @"row11": @"endtime", @"row12": @"progresspercentage", @"row13": @"isactive", @"row14": @"title", @"row15": @"hastimer", + @"row16": @"plotoutline", }, @{ @@ -4777,13 +4779,14 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N @"row6": @"broadcastid", @"playlistid": @PLAYERID_VIDEO, @"row8": @"broadcastid", - @"row9": @"plotoutline", + @"row9": @"broadcastid", @"row10": @"starttime", @"row11": @"endtime", @"row12": @"progresspercentage", @"row13": @"isactive", @"row14": @"title", @"row15": @"hastimer", + @"row16": @"plotoutline", }, @[], @@ -5045,9 +5048,10 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N @"row6": @"channelid", @"playlistid": @PLAYERID_VIDEO, @"row8": @"channelid", - @"row9": @"isrecording", - @"row10": @"channelnumber", - @"row11": @"type", + @"row9": @"channelid", + @"row10": @"isrecording", + @"row11": @"channelnumber", + @"row12": @"type", }, @{ @@ -5224,13 +5228,14 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N @"row6": @"broadcastid", @"playlistid": @PLAYERID_VIDEO, @"row8": @"broadcastid", - @"row9": @"plotoutline", + @"row9": @"broadcastid", @"row10": @"starttime", @"row11": @"endtime", @"row12": @"progresspercentage", @"row13": @"isactive", @"row14": @"title", @"row15": @"hastimer", + @"row16": @"plotoutline", }, @{ @@ -5328,13 +5333,14 @@ - (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(N @"row6": @"broadcastid", @"playlistid": @PLAYERID_VIDEO, @"row8": @"broadcastid", - @"row9": @"plotoutline", + @"row9": @"broadcastid", @"row10": @"starttime", @"row11": @"endtime", @"row12": @"progresspercentage", @"row13": @"isactive", @"row14": @"title", @"row15": @"hastimer", + @"row16": @"plotoutline", }, @[], From af285607010821cd49bd5f738fceb7957bb757f3 Mon Sep 17 00:00:00 2001 From: wutschel Date: Mon, 23 Dec 2024 09:23:11 +0100 Subject: [PATCH 10/13] Use same key for all conditions in startPlayback --- XBMC Remote/DetailViewController.m | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index 1024b913b..045428dee 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4295,10 +4295,10 @@ - (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath usin } UIActivityIndicatorView *cellActivityIndicator = [self getCellActivityIndicator:indexPath]; [cellActivityIndicator startAnimating]; - if ([mainFields[@"row8"] isEqualToString:@"channelid"] || - [mainFields[@"row8"] isEqualToString:@"broadcastid"]) { - NSNumber *channelid = item[mainFields[@"row8"]]; - if ([mainFields[@"row8"] isEqualToString:@"broadcastid"]) { + if ([mainFields[@"row9"] isEqualToString:@"channelid"] || + [mainFields[@"row9"] isEqualToString:@"broadcastid"]) { + NSNumber *channelid = item[key]; + if ([mainFields[@"row9"] isEqualToString:@"broadcastid"]) { channelid = item[@"pvrExtraInfo"][@"channelid"]; } NSDictionary *itemParams = @{ From 909943cbab15f7a65061b479e19f8ba02860795e Mon Sep 17 00:00:00 2001 From: wutschel Date: Mon, 23 Dec 2024 12:53:48 +0100 Subject: [PATCH 11/13] Special handling for Live TV / Radio can be removed Live TV / Radio can now be processed by the default logic inside buildPlaylistItems. --- XBMC Remote/DetailViewController.m | 70 +++++++++++++----------------- 1 file changed, 31 insertions(+), 39 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index 045428dee..ff238bcfe 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4295,47 +4295,34 @@ - (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath usin } UIActivityIndicatorView *cellActivityIndicator = [self getCellActivityIndicator:indexPath]; [cellActivityIndicator startAnimating]; - if ([mainFields[@"row9"] isEqualToString:@"channelid"] || - [mainFields[@"row9"] isEqualToString:@"broadcastid"]) { - NSNumber *channelid = item[key]; - if ([mainFields[@"row9"] isEqualToString:@"broadcastid"]) { - channelid = item[@"pvrExtraInfo"][@"channelid"]; - } - NSDictionary *itemParams = @{ - @"item": [NSDictionary dictionaryWithObjectsAndKeys: channelid, @"channelid", nil], - }; - [self playerOpen:itemParams index:indexPath indicator:cellActivityIndicator]; + id optionsKey; + id optionsValue; + if (AppDelegate.instance.serverVersion > 11) { + optionsKey = @"options"; + optionsValue = [NSDictionary dictionaryWithObjectsAndKeys: + @(shuffled), @"shuffled", + playername, @"playername", + nil]; } - else { - id optionsKey; - id optionsValue; - if (AppDelegate.instance.serverVersion > 11) { - optionsKey = @"options"; - optionsValue = [NSDictionary dictionaryWithObjectsAndKeys: - @(shuffled), @"shuffled", - playername, @"playername", - nil]; - } - id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row9"]]; - if (!playlistItems) { - [cellActivityIndicator stopAnimating]; - return; - } - NSDictionary *playbackParams = [NSDictionary dictionaryWithObjectsAndKeys: - playlistItems, @"item", - optionsValue, optionsKey, - nil]; - if (shuffled && AppDelegate.instance.serverVersion > 11) { - [[Utilities getJsonRPC] - callMethod:@"Player.SetPartymode" - withParameters:@{@"playerid": @(0), @"partymode": @NO} - onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *internalError) { - [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; - }]; - } - else { + id playlistItems = [self buildPlaylistItems:item key:mainFields[@"row9"]]; + if (!playlistItems) { + [cellActivityIndicator stopAnimating]; + return; + } + NSDictionary *playbackParams = [NSDictionary dictionaryWithObjectsAndKeys: + playlistItems, @"item", + optionsValue, optionsKey, + nil]; + if (shuffled && AppDelegate.instance.serverVersion > 11) { + [[Utilities getJsonRPC] + callMethod:@"Player.SetPartymode" + withParameters:@{@"playerid": @(0), @"partymode": @NO} + onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *internalError) { [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; - } + }]; + } + else { + [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; } } @@ -4400,6 +4387,11 @@ - (id)buildPlaylistItems:(NSDictionary*)item key:(id)key { key = @"file"; value = item[@"file"]; } + else if ([key isEqualToString:@"channelid"] || + [key isEqualToString:@"broadcastid"]) { + key = @"channelid"; + value = item[@"pvrExtraInfo"][@"channelid"] ?: item[@"channelid"]; + } if (!value || !key) { return nil; } From c96dca0360d18509f3ba5f3661f3a293e45ea053 Mon Sep 17 00:00:00 2001 From: wutschel Date: Wed, 25 Dec 2024 14:16:14 +0100 Subject: [PATCH 12/13] Setting indexPath when playing an item in Favourites This enables the activity indicator. --- XBMC Remote/DetailViewController.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index ff238bcfe..3d3970fca 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -1594,7 +1594,7 @@ - (void)didSelectItemAtIndexPath:(NSIndexPath*)indexPath item:(NSDictionary*)ite // Selected favourite item is a media type -> play it else if ([item[@"type"] isEqualToString:@"media"]) { if (item[@"path"]) { - [self playerOpen:@{@"item": @{@"file": item[@"path"]}} index:nil]; + [self playerOpen:@{@"item": @{@"file": item[@"path"]}} index:indexPath]; } } // Selected favourite item is an unknown type -> throw an error From 0713dd60173526712be0af912adde27e151bb251 Mon Sep 17 00:00:00 2001 From: wutschel Date: Wed, 25 Dec 2024 14:17:31 +0100 Subject: [PATCH 13/13] Remove unused parameter from playerOpen Only either indexPath or the ActivityIndicator is needed. --- XBMC Remote/DetailViewController.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/XBMC Remote/DetailViewController.m b/XBMC Remote/DetailViewController.m index 3d3970fca..a30f4f678 100644 --- a/XBMC Remote/DetailViewController.m +++ b/XBMC Remote/DetailViewController.m @@ -4261,10 +4261,10 @@ - (void)addToPlaylist:(NSDictionary*)playlistParams indicator:(UIActivityIndicat - (void)playerOpen:(NSDictionary*)params index:(NSIndexPath*)indexPath { UIActivityIndicatorView *cellActivityIndicator = [self getCellActivityIndicator:indexPath]; - [self playerOpen:params index:indexPath indicator:cellActivityIndicator]; + [self playerOpen:params indicator:cellActivityIndicator]; } -- (void)playerOpen:(NSDictionary*)params index:(NSIndexPath*)indexPath indicator:(UIActivityIndicatorView*)cellActivityIndicator { +- (void)playerOpen:(NSDictionary*)params indicator:(UIActivityIndicatorView*)cellActivityIndicator { [cellActivityIndicator startAnimating]; [[Utilities getJsonRPC] callMethod:@"Player.Open" withParameters:params onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *error) { [cellActivityIndicator stopAnimating]; @@ -4318,11 +4318,11 @@ - (void)startPlayback:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath usin callMethod:@"Player.SetPartymode" withParameters:@{@"playerid": @(0), @"partymode": @NO} onCompletion:^(NSString *methodName, NSInteger callId, id methodResult, DSJSONRPCError *methodError, NSError *internalError) { - [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; + [self playerOpen:playbackParams indicator:cellActivityIndicator]; }]; } else { - [self playerOpen:playbackParams index:indexPath indicator:cellActivityIndicator]; + [self playerOpen:playbackParams indicator:cellActivityIndicator]; } } @@ -4359,7 +4359,7 @@ - (void)startSlideshow:(NSDictionary*)item indexPath:(NSIndexPath*)indexPath { } }; } - [self playerOpen:playbackParams index:nil indicator:cellActivityIndicator]; + [self playerOpen:playbackParams indicator:cellActivityIndicator]; } - (id)buildPlaylistItems:(NSDictionary*)item key:(id)key {