Consider this branch of the Fuse Showcase. https://github.com/dfabulich/skipapp-showcase-fuse/tree/audio-bug-example
In dfabulich/skipapp-showcase-fuse@3b4d8c4 there's a very basic start of an audio playground.
import SwiftUI
#if canImport(SkipAV)
import SkipAV
#else
import AVKit
#endif
struct AudioPlayerPlayground: View {
let audioPlayer = try? AVAudioPlayer(contentsOf: URL(string: "https://dare.wisc.edu/wp-content/uploads/sites/1051/2017/08/HI009clip.mp3")!)
var body: some View {
Text("Hello, World!")
.task {
logger.log("creating delegate")
let delegate = AudioPlayerDelegate()
logger.log("setting delegate")
audioPlayer?.delegate = delegate
logger.log("playing")
audioPlayer?.play()
}
}
}
class AudioPlayerDelegate: NSObject, AVAudioPlayerDelegate {
func audioPlayerDidFinishPlaying(_ player: AVAudioPlayer, successfully flag: Bool) {
print("Finished playing")
}
}
It builds just fine, but if you launch it on Android and navigate to the audio playground, the app will crash, with this error:
SkipBridge/BridgedTypes.swift:198: Fatal error: Unable to bridge Swift instance <AudioPlayerDelegate: 0xb40000706ae94ab0> of type: AudioPlayerDelegate
It seems like it's not possible to implement a protocol in Fuse code and pass it to transpiled Kotlin.
Consider this branch of the Fuse Showcase. https://github.com/dfabulich/skipapp-showcase-fuse/tree/audio-bug-example
In dfabulich/skipapp-showcase-fuse@3b4d8c4 there's a very basic start of an audio playground.
It builds just fine, but if you launch it on Android and navigate to the audio playground, the app will crash, with this error:
It seems like it's not possible to implement a protocol in Fuse code and pass it to transpiled Kotlin.