admin管理员组文章数量:1287622
Does anyone know how to access video and json files in the new versions of swift playgrounds?
I'm trying to access throught Bundle url or path, but it's not working.
My files are inside Resources folder.
I tried this way using path:
if let path = Bundle.main.path(forResource: "helloASL", ofType: "mp4") {
let url = URL.init(filePath: path)
let item = AVPlayerItem(url: url)
VideoPlayer(player: AVPlayer(playerItem: item))
} else {
Text("Video not found")
}
this using url:
if let url = Bundle.main.url(forResource: "helloASL", withExtension: "mp4") {
VideoPlayer(player: AVPlayer(url: url))
.frame(height: 300) // Set the desired frame size
.onAppear {
AVPlayer(url: url).play()
}
} else {
Text("Video not found")
}
本文标签: swiftuiHow to access Bundle in swift PlaygroundStack Overflow
版权声明:本文标题:swiftui - How to access Bundle in swift Playground? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741318134a2372042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论