gpt4 book ai didi

objective-c - 如何在第三方音乐应用程序中获取正在播放的信息?

转载 作者:行者123 更新时间:2023-11-29 13:30:32 25 4
gpt4 key购买 nike

我想获取正在播放的信息。

所以,按照这段代码:

NSDictionary *info = [[MPNowPlayingInfoCenter defaultCenter] nowPlayingInfo];
NSString *title = [info valueForKey:MPMediaItemPropertyTitle];
NSLog(@"%@",title);
MPMusicPlayerController *pc = [MPMusicPlayerController iPodMusicPlayer];
MPMediaItem *playingItem = [pc nowPlayingItem];
if (playingItem) {
NSInteger mediaType = [[playingItem valueForProperty:MPMediaItemPropertyMediaType] integerValue];
if (mediaType == MPMediaTypeMusic) {
NSString *songTitle = [playingItem valueForProperty:MPMediaItemPropertyTitle];
NSString *albumTitle = [playingItem valueForProperty:MPMediaItemPropertyAlbumTitle];
NSString *artist = [playingItem valueForProperty:MPMediaItemPropertyArtist];
NSString *genre = [playingItem valueForProperty:MPMediaItemPropertyGenre];
TweetTextField.text = [NSString stringWithFormat:@"#nowplaying %@ - %@ / %@ #%@", artist, songTitle, albumTitle,genre];
MPMediaItemArtwork *artwork = [playingItem valueForProperty:MPMediaItemPropertyArtwork];
CGSize newSize = CGSizeMake(250, 250);
UIGraphicsBeginImageContext(newSize);
[[artwork imageWithSize:CGSizeMake(100.0, 100.0)] drawInRect:CGRectMake(0, 0, newSize.width, newSize.height)];
UIImage* newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
_imageView.image = newImage;
}
if (_imageView.image == nil){
} else {
_tableView.alpha=0.5;
}
}

但是这段代码可以从默认的 iPod 应用程序获取正在播放的信息。

如何在第三方音乐应用程序中获取正在播放的信息?(例如:Mobile Safari、Youtube App、gMusic、Melodies 等)。

最佳答案

我认为这是不可能的。 documentation声明 MPNowPlayingInfoCenter 仅用于设置锁定屏幕上的信息。

这里是 a related question .

关于objective-c - 如何在第三方音乐应用程序中获取正在播放的信息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12017983/

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