[ios] CoreVideo 프레임워크에서의 영상 재생 및 스트리밍 기능

CoreVideo 프레임워크는 iOS 애플리케이션에서 영상 재생과 스트리밍을 구현하는 데 유용한 기능을 제공합니다.

영상 재생

CoreVideo를 사용하여 iOS 애플리케이션에서 영상을 재생할 때, AVPlayer 클래스를 활용하여 영상을 로드하고 재생할 수 있습니다. 다음은 간단한 예제 코드입니다:

import AVKit

let videoURL = URL(string: "https://www.example.com/video.mp4")
let player = AVPlayer(url: videoURL)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
present(playerViewController, animated: true) {
    player.play()
}

영상 스트리밍

CoreVideo를 사용하여 iOS 애플리케이션에서 영상을 스트리밍할 때, AVPlayerViewController를 통해 URL을 로드하여 스트리밍할 수 있습니다. 다음은 간단한 예제 코드입니다:

import AVKit

let videoURL = URL(string: "https://www.example.com/streaming/video.m3u8")
let player = AVPlayer(url: videoURL)
let playerViewController = AVPlayerViewController()
playerViewController.player = player
present(playerViewController, animated: true) {
    player.play()
}

결론

CoreVideo 프레임워크는 iOS 애플리케이션에서 영상 재생 및 스트리밍 기능을 구현하는 데 매우 유용한 도구입니다. 이를 활용하여 사용자에게 매끄럽고 효과적인 영상 경험을 제공할 수 있습니다.

참고: Apple Developer Documentation - AVFoundation