Swift: Struct Does Not Conform to Protocol Decodable with MPMediaItemArtwork

237 views Asked by At

I'm uploading the current playback information from the iOS Media Player to Firebase and want to be able to include the current artwork however I can't just put it as an MPMediaItemArtwork (as seen below) as the struct does not conform to the Codable format. How can I convert it into something that is e.g. a String?

import Firebase
import CodableFirebase
import MediaPlayer

    struct LatestPlaybackItem: Codable { 
        var trackName: String
        var trackArtistName: String
        var playlistName: String
        var playbackState: String
        var currentArtwork: MPMediaItemArtwork  
    }

I've looked at these answers but not sure how to get it working with an MPMediaItemArtwork.

My structure does not conform to protocol 'Decodable' / 'Encodable'

Codable class does not conform to protocol Decodable

0

There are 0 answers