AVPlayer unable to retrieve title metadata for arbitrary items

I can't seem to identify any pattern here, but AVPlayer is unable to get the track title metadata for some ( but not all ) mp3 files, usually ones which are over an hour long. In all these instances, other metadata like artwork, artist or album title are retrieved accurately.

When synced via iTunes, the stock music app does not have any problems – and then attempting to get the title via MPMediaItem.title correctly returns the title in each case.

Code snippet below. I observed the code with breakpoints, and the problem items do not execute anything in the 2nd else-if statement for AVMetadataCommonKeyTitle, but all the other statements work as expected. And again, this code works perfectly for 99.9% of items .

Links to some non-working files: https://soundcloud.com/humboldthain/blind-observatory-3-years-of-humboldthain-closing-set-4h

https://soundcloud.com/bananamilk/mary-yuzovskaya-femalepressure-tresor-berlin-january-2017

            //Declare blank/default vars
            var artist: String = ""
            var album: String = ""
            var track: String = ""
            var artwork: UIImage! = UIImage(named: "defaultArtwork")


            //Metadata loop
            for i in asset!.commonMetadata {
                if i.commonKey == AVMetadataCommonKeyArtist {
                    artist = i.value as! String
                }
                else if i.commonKey == AVMetadataCommonKeyTitle {
                    track = i.value as! String
                }
                else if i.commonKey == AVMetadataCommonKeyAlbumName {
                    album = i.value as! String
                }
                else if i.commonKey == AVMetadataCommonKeyArtwork {
                    artwork = UIImage(data: i.value as! Data)
                }
            }
链接地址: http://www.djcxy.com/p/66070.html

上一篇: javascript onclick,匿名函数

下一篇: AVPlayer无法检索任意项目的标题元数据