This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Example of a way to read in serialized data (eg. json) when Swift adds built in | |
Codable / Hashable / Equatible to a struct / class that previously didn't, yet they decided | |
to serialize things differently than you did in existing code. | |
In this example, I had previously serialized int2 to a dictionary with x and y keys for its | |
x and y properties. Swift 5 serializes this as an array, which is incompatible and causes | |
the whole json file to fail to deserialize. | |
You could write a custom init(from decoder: Decoder for each class using the problematic struct, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let player = AVPlayer() | |
func playFileAtURL(url: NSURL) { | |
let asset = AVAsset.assetWithURL(url) as AVAsset | |
let duration = asset.duration | |
let durationInSeconds = CMTimeGetSeconds(duration) | |
let item = AVPlayerItem(asset: asset) | |
let params = AVMutableAudioMixInputParameters(track: asset.tracks.first! as AVAssetTrack) |