Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
52 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// | ||
// GuideViewModel.swift | ||
// koget | ||
// | ||
// Created by HeonJin Ha on 10/23/23. | ||
// | ||
|
||
import Foundation | ||
import AVKit | ||
|
||
final class GuideViewModel: ObservableObject { | ||
|
||
let video: (player: AVPlayer, looper: AVPlayerLooper) = { | ||
let videoURL = Bundle.main.url(forResource: "guide1", withExtension: "mp4")! | ||
let asset = AVAsset(url: videoURL) | ||
let item = AVPlayerItem(asset: asset) | ||
let queuePlayer = AVQueuePlayer(playerItem: item) | ||
let playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: item) | ||
|
||
return (queuePlayer, playerLooper) | ||
}() | ||
|
||
let video2: (player: AVPlayer, looper: AVPlayerLooper) = { | ||
let videoURL = Bundle.main.url(forResource: "guide2", withExtension: "mp4")! | ||
let asset = AVAsset(url: videoURL) | ||
let item = AVPlayerItem(asset: asset) | ||
let queuePlayer = AVQueuePlayer(playerItem: item) | ||
let playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: item) | ||
|
||
return (queuePlayer, playerLooper) | ||
}() | ||
|
||
let video3: (player: AVPlayer, looper: AVPlayerLooper) = { | ||
let videoURL = Bundle.main.url(forResource: "guide3", withExtension: "mp4")! | ||
let asset = AVAsset(url: videoURL) | ||
let item = AVPlayerItem(asset: asset) | ||
let queuePlayer = AVQueuePlayer(playerItem: item) | ||
let playerLooper = AVPlayerLooper(player: queuePlayer, templateItem: item) | ||
|
||
return (queuePlayer, playerLooper) | ||
}() | ||
|
||
} |