# 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))
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jacky-chen.gitbook.io/jackychen/ar-vr/arkit.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
