我有这段代码:
-(NSURL *)urlOfCurrentlyPlayingInPlayer:(AVPlayer *)player{
// get current asset
AVAsset *currentPlayerAsset = player.currentItem.asset;
// make sure the current asset is an AVURLAsset
if (![currentPlayerAsset isKindOfClass:AVURLAsset.class]) return nil;
// return the NSURL
return [(AVURLAsset *)currentPlayerAsset URL];
}
为什么我不能这样做?
NSURL *currentSong=[urlOfCurrentlyPlayingInPlayer:_audioPlayer1];
错误消息是“预期表达式”,NSURL的N用红色下划线标出
抱歉noob问题
答案 0 :(得分:1)
假设urlOfCurrentlyPlayingInPlayer
在同一个类中声明:
NSURL *currentSong = [self urlOfCurrentlyPlayingInPlayer:_audioPlayer1];
如果它是某个其他类的实例方法,那么它将是
NSURL *currentSong = [myInstanceOfSomeOtherClass urlOfCurrentlyPlayingInPlayer:_audioPlayer1];