Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify queue and play method of DetailViewController and ShowInfoViewController #740

Open
wutschel opened this issue Oct 13, 2022 · 3 comments

Comments

@wutschel
Copy link
Collaborator

Inside controllers DetailViewController and ShowInfoViewController there are methods to add items to the playlist queue and to start playback. Those are very similar and should be unified into generic methods. Methods of interest are

DetailViewController:

  • (void)addQueue:(NSDictionary*) indexPath:(NSIndexPath*) afterCurrentItem:(BOOL)
  • (void)addPlayback:(NSDictionary*) indexPath:(NSIndexPath*) position:(int) shuffle:(BOOL)

ShowInfoViewController

  • (void)addQueueAfterCurrent:(BOOL)
  • (void)addPlayback:(float)
@AbdelAzizMohamedMousa
Copy link

Thank you for your question. It sounds like you are looking to unify the add queue and playback methods in the DetailViewController and ShowInfoViewController controllers into generic methods.

To achieve this, you could create a separate class or extension that contains the generic methods for adding items to the playlist queue and starting playback. This class could then be imported and used in both the DetailViewController and ShowInfoViewController classes.

Here is an example of what these generic methods might look like:
`@interface MyPlaylistManager : NSObject

  • (void)addToQueue:(NSDictionary *)item afterCurrentItem:(BOOL)afterCurrent;
  • (void)startPlayback:(NSDictionary *)item position:(int)position shuffle:(BOOL)shuffle;

@EnD

@implementation MyPlaylistManager

  • (void)addToQueue:(NSDictionary *)item afterCurrentItem:(BOOL)afterCurrent {
    // Logic for adding item to the playlist queue
    }

  • (void)startPlayback:(NSDictionary *)item position:(int)position shuffle:(BOOL)shuffle {
    // Logic for starting playback of the specified item at the specified position
    }

@EnD
`

You could then call these methods from the DetailViewController and ShowInfoViewController classes, passing in the appropriate parameters as needed:

`// Example usage in DetailViewController
[MyPlaylistManager addToQueue:item afterCurrentItem:YES];
[MyPlaylistManager startPlayback:item position:0 shuffle:NO];

// Example usage in ShowInfoViewController
[MyPlaylistManager addToQueue:item afterCurrentItem:NO];
[MyPlaylistManager startPlayback:item position:0 shuffle:YES];
`

I hope this helps, and let me know if you have any further questions or concerns.

@wutschel
Copy link
Collaborator Author

Good progress with some local changes I already prepared. The solution reworks the addQeue and addPlayback methods to be able to separate out common code which is then placed in a newly created class AppBaseViewController. Both DetailViewController and ShowInfoViewController will be derived from this. This approach also potentially allows to move methods from Utilities into this new class, like SFloadURL, or further unify playback commands used in RemoteViewController and NowPlaying.

@wutschel
Copy link
Collaborator Author

Should also investigate the same for recordChannel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants