修复了声音秀每次进入不同的人播放的是第一个人的声音秀

This commit is contained in:
fengshuo
2022-08-25 11:35:32 +08:00
parent 413bbe850e
commit 393acb13d7
5 changed files with 18 additions and 7 deletions

View File

@@ -17,7 +17,7 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic,copy) NSString *icon;
///技能
@property (nonatomic,copy) NSArray *propVals;
///
///名字
@property (nonatomic,copy) NSString *name;
@end

View File

@@ -56,6 +56,7 @@
[self.player stop];
self.player = nil;
}
NSLog(@"播放动画的路径:%@", filePath);
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) return;
NSURL *url = [NSURL fileURLWithPath:filePath];
NSError *AVerror = NULL;

View File

@@ -116,6 +116,7 @@ XPSkillCardListCellDelegate
- (void)onDeleteSkillCardSuccess {
[self showErrorToast:@"删除成功"];
[self.presenter getSkillCardInfoWithUid:[NSString stringWithFormat:@"%zd", self.uid]];
[[XPSkillCardPlayerManager shareInstance] stopMusic];
}
#pragma mark - XPSkillCardTypeViewDelegate
@@ -282,7 +283,7 @@ XPSkillCardListCellDelegate
return [NSURL fileURLWithPath:filePath];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
if (!error) {
completion(YES, filePath.absoluteString);
completion(YES, filePath.path);
} else {
completion(NO, nil);
}

View File

@@ -74,10 +74,17 @@
sender.selected = !sender.selected;
if (!self.isPlaying) {
if(self.voiceInfo.propVals.count) {
NSString *fileName = [[self.voiceInfo.name componentsSeparatedByString:@"/"] lastObject];
// NSString *fileName = [[self.voiceInfo.name componentsSeparatedByString:@"/"] lastObject];
NSString * url = [self.voiceInfo.propVals objectAtIndex:0];
NSArray * nameArray = [url componentsSeparatedByString:@"/"];
NSString * fileName = @"daeplay";
if (nameArray.count > 0) {
fileName = nameArray.lastObject;
}
NSString *filePath = [[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0] stringByAppendingPathComponent:@"mineSkillCardVoice"];
NSString *fullPath = [filePath stringByAppendingPathComponent:fileName];
NSLog(@"下载的路径:%@", fullPath);
if ([[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
self.isPlaying = YES;
sender.selected = YES;
@@ -90,9 +97,11 @@
[[XPSkillCardPlayerManager shareInstance] stopMusic];
}];
} else {
if (![[NSFileManager defaultManager] fileExistsAtPath:filePath]) {
if (![[NSFileManager defaultManager] fileExistsAtPath:fullPath]) {
NSFileManager *fileMgr = [[NSFileManager alloc] init];
[fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:nil];
NSError * error;
[fileMgr createDirectoryAtPath:filePath withIntermediateDirectories:YES attributes:nil error:&error];
NSLog(@"%@", error.description);
}
[self downloadAudioWithFileName:fileName musicUrl:url completion:^(BOOL isSuccess, NSString *editAudioPath) {
self.isPlaying = YES;
@@ -126,7 +135,7 @@
return [NSURL fileURLWithPath:filePath];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
if (!error) {
completion(YES, filePath.absoluteString);
completion(YES, filePath.path);
} else {
completion(NO, nil);
}

View File

@@ -298,7 +298,7 @@
return [NSURL fileURLWithPath:filePath];
} completionHandler:^(NSURLResponse * _Nonnull response, NSURL * _Nullable filePath, NSError * _Nullable error) {
if (!error) {
completion(YES, filePath.absoluteString);
completion(YES, filePath.path);
} else {
completion(NO, nil);
}