Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/41.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 流媒体-如何使用AVAsset获取歌曲名称_Iphone_Objective C_Ios5 - Fatal编程技术网

Iphone 流媒体-如何使用AVAsset获取歌曲名称

Iphone 流媒体-如何使用AVAsset获取歌曲名称,iphone,objective-c,ios5,Iphone,Objective C,Ios5,我正在尝试从一个URL加载一个强项,并获取当前播放歌曲的标题 这首歌正在播放。一切都很好,直到我撞上这堵“获得歌曲名称”的墙。不幸的是NSLog(@“key=%@,value=%@”,key,value)不返回任何内容。几乎被困在这里了 AVURLAsset *newAsset =[AVURLAsset assetWithURL:audioFileURL]; [newAsset loadValuesAsynchronouslyForKeys:keys completionHandler:

我正在尝试从一个URL加载一个强项,并获取当前播放歌曲的标题

这首歌正在播放。一切都很好,直到我撞上这堵“获得歌曲名称”的墙。不幸的是
NSLog(@“key=%@,value=%@”,key,value)不返回任何内容。几乎被困在这里了

AVURLAsset *newAsset =[AVURLAsset assetWithURL:audioFileURL];
    [newAsset loadValuesAsynchronouslyForKeys:keys completionHandler:^{

        NSError *error = nil;
        AVKeyValueStatus durationStatus = [newAsset statusOfValueForKey:@"commonMetadata" error:&error];

        switch (durationStatus) {
            case AVKeyValueStatusLoaded: {
                playerItem = [AVPlayerItem playerItemWithAsset:newAsset];
                self.player = [AVPlayer playerWithPlayerItem:playerItem];

                NSArray *songMeta = [newAsset commonMetadata];

                for (AVMetadataItem *item in songMeta ) {
                    NSString *key = [item commonKey];
                    NSString *value = [item stringValue];
                    NSLog(@"key = %@, value = %@", key, value);
                }

                break;
            }
            case AVKeyValueStatusFailed:
                NSLog(@"Failed");
                break;
            default:
                NSLog(@"Default");
                break;
        }
    }];

谢谢

你加载的歌曲真的有元数据吗?我不认为这有什么关系,但我总是看到N错误*错误。not NSError*error=nil。@sch可能没有,但我确信流会发送名称。除了元数据,还有什么其他发送歌曲名称的方法?@Eric你可能是对的。我现在正在学习。可能是个错误。我会调查的。谢谢