2016-07-04 18 views
0

So richten Hintergrund iOS Medien AVPlayer Gefällt Ihnen dieses enter image description hereWie AVPlayer Controller im Lock-Modus iOS

linken und rechten Seite Spieler nötig sind, um zu setzen.

Bis jetzt, was ich erreicht habe, ist enter image description here

Alle play pause previous next arbeiten, aber ich brauche songName, artistName, albumArt, seekBar.

Wie das tun angezeigt werden? Bitte geben Sie alle Artikel

+0

meine Antwort Chek .............................. –

Antwort

1

Sie müssen Informationen in MPNowPlayingInfoCenter wie folgt festlegen.

Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter"); 

    if (playingInfoCenter) { 


     NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init]; 

     MPMediaItemArtwork *albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imageNamed:@"AlbumArt"]]; 


     NSArray *keys = [NSArray arrayWithObjects: 
         MPMediaItemPropertyTitle, 
         MPMediaItemPropertyArtist, 
         MPMediaItemPropertyPlaybackDuration, 
         MPNowPlayingInfoPropertyPlaybackRate, 
         nil]; 

     NSError *playerError; 

//  AVAudioPlayer* audioPlayer4 = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"This That (Dil Wali Gal) - Ammy Virk (DJJOhAL.Com)" ofType:@".mp3"]] error:&playerError]; 
//   
//  NSLog(@"%f",audioPlayer4.duration); 

     NSArray *values = [NSArray arrayWithObjects: 
          @"DIL vali gal", 
          @"ammy virk", 
          @"30", 
          [NSNumber numberWithInt:1], 
          nil]; 
     NSDictionary *mediaInfo = [NSDictionary dictionaryWithObjects:values forKeys:keys]; 



     [songInfo setObject:@"Audio Title" forKey:MPMediaItemPropertyTitle]; 
     [songInfo setObject:@"Audio Author" forKey:MPMediaItemPropertyArtist]; 
     [songInfo setObject:@"Audio Album" forKey:MPMediaItemPropertyAlbumTitle]; 
     [songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork]; 
     [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:mediaInfo]; 


    } 

und importieren diese Frameworks

#import <AVFoundation/AVFoundation.h> 
#import <MediaPlayer/MPMoviePlayerController.h> 
+0

Wo sollte ich diese Klasse –

+0

hinzufügen, wenn Sie das Lied spielen. füge alle Informationen darin hinzu. –

+0

überprüfen update antar –