带音频播放器的Iphone应用程序

时间:2011-10-12 08:09:16

标签: iphone avaudioplayer

我在应用程序的文档文件夹中添加了音乐文件,我正在播放来自AVAudioPlayer的音乐。如何获得其标题,专辑名称和艺术家姓名。

我使用MPmediaPlayer访问ipod库。但现在我想制作我的自定义播放器。有没有必要在这种类型的应用程序中使用mpmediaplayer。我已经获得了ipod歌曲的专辑标题和艺术作品图像

我试图让它像

NSError *activationError = nil;     
[[AVAudioSession sharedInstance] setActive: YES error: &activationError];

    // Instantiates the AVAudioPlayer object, initializing it with the sound    AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: soundFileURL error: nil];  self.appSoundPlayer
= newPlayer;

    musicPlayer = [MPMusicPlayerController applicationMusicPlayer];
    MPMediaItem *item = musicPlayer.nowPlayingItem ;

    nowPlayingLabel.text = [item valueForProperty:MPMediaItemPropertyTitle];
    NSLog(@"title %@",[item valueForProperty:MPMediaItemPropertyTitle]);    [newPlayer release];        // "Preparing to play" attaches to the audio hardware and ensures that playback     //      starts quickly when the user taps Play  [appSoundPlayer prepareToPlay];     [appSoundPlayer setVolume: 1.0];    [appSoundPlayer setDelegate: self];

    [appSoundPlayer currentTime];

标题正在返回(null)

请帮助..

0 个答案:

没有答案