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

Reordering issue #102

Closed
praveenkumar56060 opened this issue Jan 29, 2016 · 7 comments
Closed

Reordering issue #102

praveenkumar56060 opened this issue Jan 29, 2016 · 7 comments

Comments

@praveenkumar56060
Copy link

Hello Saiday,

As new version (2.1.5) released with lot of new methods and implementations. I am facing an issue while reordering songs in my Queue.

Like, i've populated all my song data in a TableView. User can pick any song. So, while playing a song, he/she can reorder it. If the user reorder the current playing song, the index of the current items are not changing (I have debugged this) Instead, it works with previous order.

So, how can i manually reset the Index of current song with HysteriaOrder method

@saiday For your reference, please try this SamplePlayer

@saiday
Copy link
Member

saiday commented Jan 29, 2016

It's great to see a sample indicating your issue. thanks.
But I was not able to build your sample, PlayerCell.h:10:9: 'VYPlayIndicator.h' file not found

It takes me more time to figure it out, if could, could you please upload new sample?

@saiday
Copy link
Member

saiday commented Jan 29, 2016

@praveenkumartapmobi it's ok, I fix it by use any dumb view instead. Never mind.

@saiday saiday closed this as completed in cca13ae Jan 29, 2016
@saiday
Copy link
Member

saiday commented Jan 29, 2016

@praveenkumartapmobi Thank you, it's a HysteriaPlayer's bug. Been fixed by cca13ae.

Please update to 2.1.6 on CocoaPods.

FYI, I made a few changes in your sample to make it work.
In ViewController.m Line 159 ~ 165

- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)sourceIndexPath toIndexPath:(NSIndexPath *)destinationIndexPath {
    id object = [songRecords objectAtIndex:sourceIndexPath.row];
    [songRecords removeObjectAtIndex:sourceIndexPath.row];
    [songRecords insertObject:object atIndex:destinationIndexPath.row];
    [[HysteriaPlayer sharedInstance] moveItemFromIndex:sourceIndexPath.row toIndex:destinationIndexPath.row];
    [tableView reloadData];
}

@praveenkumar56060
Copy link
Author

You can have the "VYPlayIndicator" here

@praveenkumar56060
Copy link
Author

No, the issue still remains there. As i have told you i have disabled the [hysteriaPlayer enableMemoryCached:NO];

So, when we disable the cachememory in HysteiraPlayer. The, self.playerItems will not contains any items. In that case, how could we handle this?

@saiday
Copy link
Member

saiday commented Jan 29, 2016

@praveenkumartapmobi Yes, that was a bug. And I just fixed it.
Please see:

- (void)moveItemFromIndex:(NSInteger)from toIndex:(NSInteger)to
{
for (AVPlayerItem *item in self.playerItems) {
[self resetItemIndexIfNeeds:item fromIndex:from toIndex:to];
}
for (AVPlayerItem *item in self.audioPlayer.items) {
if ([self resetItemIndexIfNeeds:item fromIndex:from toIndex:to]) {
[self removeQueuesAtPlayer];
}
}
}
- (BOOL)resetItemIndexIfNeeds:(AVPlayerItem *)item fromIndex:(NSInteger)sourceIndex toIndex:(NSInteger)destinationIndex
{
NSInteger checkIndex = [[self getHysteriaIndex:item] integerValue];
if (checkIndex == sourceIndex || checkIndex == destinationIndex) {
NSNumber *replaceOrder = checkIndex == sourceIndex ? [NSNumber numberWithInteger:destinationIndex] : [NSNumber numberWithInteger:sourceIndex];
[self setHysteriaIndex:item key:replaceOrder];
return YES;
}
return NO;
}

@praveenkumar56060
Copy link
Author

Yes, it got fixed. Thanks :)

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

No branches or pull requests

2 participants