1

現在、Swift 3 を使用してポッドキャスト プレーヤーを作成していますが、ポッドキャスト ファイルに関連付けられたすべての「非表示」データ (メタデータ) にアクセスする際に問題があります。

具体的には、Apple の Podcast アプリでは、「コメント」または詳細な説明が表示されます。この情報は、これまでにアプリ全体を作成した方法である MPMediaPlayer を使用している場合は利用できません。

この投稿は正しい方向に進んでいるように見えますが、Swift を使用している私には十分に具体的ではありません: iPodLibrary からポッドキャスト メタデータを取得する

この追加情報にアクセスするにはどうすればよいですか?

または、リンクされたコード (Obj-C) を Swit 3 アプリに実装する方法はありますか?

編集:

OK、解決に少しずつ近づいています。ただし、次の構造の特定のキーに到達する方法がわかりません。

まず、ポッドキャスト (アイテム) をこの関数に送信する現在のコードを次に示します。

///////// key=TDS
func getMeta(_ item: MPMediaItem){
    print("")
    print("--------- GETMETA ---------")
    let url = item.value(forProperty:MPMediaItemPropertyAssetURL) as? NSURL
    let asset = AVURLAsset(url: url as! URL, options: nil)

    let formatsKey = "availableMetadataFormats"
    asset.loadValuesAsynchronously(forKeys: [formatsKey]) {
        var error: NSError? = nil
        let status = asset.statusOfValue(forKey: formatsKey, error: &error)
        if status == .loaded {
            for format in asset.availableMetadataFormats {
                let metadata = asset.metadata(forFormat: format)
                print("format:\(format)")
                print("metadata description:\(metadata.description)")
            }
        }
    }
}
/////////

特定のポッドキャストに対して次の出力が生成されます。

format:org.id3
metadata description:[<AVMetadataItem: 0x174005f40, identifier=id3/TIT2, keySpace=org.id3, key class = NSTaggedPointerString, key=TIT2, commonKey=title, extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=FriComedy:  The News Quiz 3rd Feb 2017>, <AVMetadataItem: 0x174006160, identifier=id3/TPE1, keySpace=org.id3, key class = NSTaggedPointerString, key=TPE1, commonKey=artist, extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=BBC Radio 4>, <AVMetadataItem: 0x174006310, identifier=id3/TALB, keySpace=org.id3, key class = NSTaggedPointerString, key=TALB, commonKey=albumName, extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=Friday Night Comedy from BBC Radio 4>, <AVMetadataItem: 0x174006130, identifier=id3/TCON, keySpace=org.id3, key class = NSTaggedPointerString, key=TCON, commonKey=type, extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=Podcast>, <AVMetadataItem: 0x174006320, identifier=id3/USLT, keySpace=org.id3, key class = NSTaggedPointerString, key=USLT, commonKey=(null), extendedLanguageTag=   , dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
    info = "";
}, value=Susan Calman, Andy Hamilton, Katy Brand and Lloyd Langford are amongst Miles' esteemed guests for this week's round of news-wrangling.



Theresa May won a vote, Donald Trump won a vote and François Fillon might have to drop out of a vote. Orangutans can't vote but still feature in the programme.



Producer: Richard Morris

A BBC Studios Production>, <AVMetadataItem: 0x174006330, identifier=id3/COMM, keySpace=org.id3, key class = NSTaggedPointerString, key=COMM, commonKey=(null), extendedLanguageTag=en, dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
    info = "";
}, value=Susan Calman, Andy Hamilton, Katy Brand and Lloyd Langford are amongst Miles' esteemed guests for this week's round of news-wrangling.



Theresa May won a vote, Donald Trump won a vote and François Fillon might have to drop out of a vote. Orangutans can't vote but still feature in the programme.



Producer: Richard Morris

A BBC Studios Production>, <AVMetadataItem: 0x174006340, identifier=id3/TCOP, keySpace=org.id3, key class = NSTaggedPointerString, key=TCOP, commonKey=copyrights, extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=(c) BBC 2017>, <AVMetadataItem: 0x174006350, identifier=id3/APIC, keySpace=org.id3, key class = NSTaggedPointerString, key=APIC, commonKey=artwork, extendedLanguageTag=(null), dataType=com.apple.metadata.datatype.JPEG, time={INVALID}, duration={INVALID}, startDate=(null), extras={
    dataType = "image/jpeg";
    dataTypeNamespace = "org.iana.media-type";
    info = "";
    pictureType = "Cover (front)";
}, value length=50551>, <AVMetadataItem: 0x174006360, identifier=id3/TIT3, keySpace=org.id3, key class = NSTaggedPointerString, key=TIT3, commonKey=description, extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=A satirical review of the week's news, chaired by Miles Jupp>, <AVMetadataItem: 0x174006370, identifier=id3/TYER, keySpace=org.id3, key class = NSTaggedPointerString, key=TYER, commonKey=(null), extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=2017>, <AVMetadataItem: 0x174006380, identifier=id3/TDRL, keySpace=org.id3, key class = NSTaggedPointerString, key=TDRL, commonKey=(null), extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=2017-02-03T18:57:00Z>, <AVMetadataItem: 0x174006390, identifier=id3/COMM, keySpace=org.id3, key class = NSTaggedPointerString, key=COMM, commonKey=(null), extendedLanguageTag=en, dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
    info = iTunPGAP;
}, value=0>, <AVMetadataItem: 0x1740063a0, identifier=id3/PCST, keySpace=org.id3, key class = NSTaggedPointerString, key=PCST, commonKey=(null), extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value length=4>, <AVMetadataItem: 0x1740063b0, identifier=id3/TDES, keySpace=org.id3, key class = NSTaggedPointerString, key=TDES, commonKey=(null), extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=Susan Calman, Andy Hamilton, Katy Brand and Lloyd Langford are amongst Miles' esteemed guests for this week's round of news-wrangling.



Theresa May won a vote, Donald Trump won a vote and François Fillon might have to drop out of a vote. Orangutans can't vote but still feature in the programme.



Producer: Richard Morris

A BBC Studios Production>, <AVMetadataItem: 0x1740063c0, identifier=id3/TGID, keySpace=org.id3, key class = NSTaggedPointerString, key=TGID, commonKey=(null), extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=urn:bbc:podcast:p04rt97d>, <AVMetadataItem: 0x1740063d0, identifier=id3/WFED, keySpace=org.id3, key class = NSTaggedPointerString, key=WFED, commonKey=(null), extendedLanguageTag=(null), dataType=(null), time={INVALID}, duration={INVALID}, startDate=(null), extras={
}, value=%00http://www.bbc.co.uk/programmes/p02pc9pj/episodes/downloads.rss%00>]

key=TDESおよび/またはのテキスト/値を分離しようとしていますidentifier=id3/TDES

4

1 に答える 1