ARKit
教學連結
An introduction to ARKit 2 — Image Tracking (串 AVPlayer 影片範例)
// Load video and create video player
let videoPlayer : AVPlayer = {
// Load cat video from bundle
guard let url = Bundle.main.url(forResource: "video", withExtension: "mp4") else {
print("Could not find video file.")
return AVPlayer()
}
return AVPlayer(url: url)
}()
let plane = SCNPlane(width: imageAnchor.referenceImage.physicalSize.width, height: imageAnchor.referenceImage.physicalSize.height)
plane.firstMaterial?.diffuse.contents = videoPlayer
self.videoPlayer.play()
Creating an Immersive AR Experience with Audio (串 Audio 音效範例)
// Instantiate the audio source
audioSource = SCNAudioSource(fileNamed: "fireplace.mp3")!
// As an environmental sound layer, audio should play indefinitely
audioSource.loops = true
// Decode the audio from disk ahead of time to prevent a delay in playback
audioSource.load()
// Create a player from the source and add it to `objectNode`
objectNode.addAudioPlayer(SCNAudioPlayer(source: audioSource))
Last updated
Was this helpful?