如何在iPhone上播放音乐在后台时设置的标题?

编程入门 行业动态 更新时间:2024-10-25 22:32:13
本文介绍了如何在iPhone上播放音乐在后台时设置的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我工作在一个电台的应用程序,它支持播放音乐的背景。但我得到停留在如何设置音乐的标题去掉控制。

I'm working on a radio app, which supports playing music in background. But i get stuck in how to set the title of music to remove control.

在遥控器,我的应用程序看起来像这样(RadioTaste是我的应用程序的名称):

In remote control, my app looks like this(RadioTaste is my app's name):

和苹果的音乐应用程序是这样的:

And Apple's "Music" app looks like this:

我应该怎么做,使我的应用程序显示一个类似乐吗?

What i should do to make my app display the title of a music like "Music" do?

谢谢!

推荐答案

完全一样的评论,这里的例子code:

exactly as in the comment , here's the example code :

#import <MediaPlayer/MPNowPlayingInfoCenter.h> #import <MediaPlayer/MPMediaItem.h> MPMediaItemArtwork *albumArt; - (void)changeTrackTitles { Class playingInfoCenter = NSClassFromString(@"MPNowPlayingInfoCenter"); if (playingInfoCenter) { albumArt = [[MPMediaItemArtwork alloc] initWithImage: [UIImage imageNamed:@"HexagonArtwork"]]; NSMutableDictionary *songInfo = [[NSMutableDictionary alloc] init]; [songInfo setObject:@"SongName" forKey:MPMediaItemPropertyTitle]; [songInfo setObject:@"AlbumName" forKey:MPMediaItemPropertyAlbumTitle]; [songInfo setObject:@"ArtistName" forKey:MPMediaItemPropertyArtist]; [songInfo setObject:albumArt forKey:MPMediaItemPropertyArtwork]; [[MPNowPlayingInfoCenter defaultCenter] setNowPlayingInfo:songInfo]; } }

我希望这将有助于..

i hope this will help..

更多推荐

如何在iPhone上播放音乐在后台时设置的标题?

本文发布于:2023-07-11 09:06:26,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1093519.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:台时   标题   如何在   音乐   iPhone

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!