我正在创建一个音乐播放器,并且我已经有了歌曲的相对路径"/Users/username/ music /song.mp3“,我的代码是
NSURL * localURL = [NSURL URLWithString:audioPath];
AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:localURL];
self.audioPlayer = [[AVPlayer alloc] initWithPlayerItem : playerItem];
self.isPlaying = @"false";
[self.audioPlayer play];
但是我的macOs应用程序不能播放任何东西,而我的song.mp3可以用iTunes播放。
发布于 2017-02-05 07:32:42
NSURL * localURL = [NSURL URLWithString:audioPath];
^^^^^^^^^^^^^
应该是
NSURL * localURL = [NSURL fileURLWithPath:audioPath];
^^^^^^^^^^^^^^^
https://stackoverflow.com/questions/42049409
复制