gpt4 book ai didi

ios - 如何在 iOS 中将 AVPlayer Controller 设置为锁定模式?

转载 作者:行者123 更新时间:2023-11-29 00:50:20 26 4
gpt4 key购买 nike

如何像这样设置背景iOS媒体AVPlayer

enter image description here

需要左右手球员。

到目前为止我所拥有的

enter image description here

所有播放、暂停、上一个、下一个都可以工作。

我需要显示songName、artistName、albumArt、seekBar。

最佳答案

您需要像这样在MPNowPlayingInfoCenter中设置信息。

 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];


}

并导入这个框架

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

关于ios - 如何在 iOS 中将 AVPlayer Controller 设置为锁定模式?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38181655/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com