> For the complete documentation index, see [llms.txt](https://jacky-chen.gitbook.io/jackychen/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jacky-chen.gitbook.io/jackychen/ar-vr/arkit.md).

# ARKit

## 教學連結

* [**Recognizing Images in an AR Experience**](https://developer.apple.com/documentation/arkit/recognizing_images_in_an_ar_experience#overview)
* [**What’s New in ARKit 2**](https://developer.apple.com/videos/play/wwdc2018/602)
* [**An introduction to ARKit 2 — Image Tracking**](https://medium.com/@mohams3ios01/an-introduction-to-arkit-2-image-tracking-730fdff4e3fa) **（串 AVPlayer 影片範例）**

```swift
// 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)
}()
```

```swift
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**](https://developer.apple.com/documentation/arkit/creating_an_immersive_ar_experience_with_audio) **（串 Audio 音效範例）**

```swift
// Instantiate the audio source
audioSource = SCNAudioSource(fileNamed: "fireplace.mp3")!
```

```swift
// 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()
```

```swift
// Create a player from the source and add it to `objectNode`
objectNode.addAudioPlayer(SCNAudioPlayer(source: audioSource))
```
