Skip to content

Commit

Permalink
Create 231201_AVPlayer,_waitingToPlayAtSpecifiedRate,_waitingToPlayAtโ€ฆ
Browse files Browse the repository at this point in the history
โ€ฆSpecifiedRate.md
  • Loading branch information
leeari95 authored Dec 1, 2023
1 parent 633c326 commit 6f3dfe7
Showing 1 changed file with 36 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# 231201 AVPlayer, waitingToPlayAtSpecifiedRate, evaluatingBufferingRate

12์›” 1์ผ (๊ธˆ)

## ํ•™์Šต ๋‚ด์šฉ
- AVPlayer๋ฅผ ๋‹ด์€ ์…€์„ ์žฌ์‚ฌ์šฉํ•  ๋•Œ, AVPlayerItem์„ ํ• ๋‹นํ•˜์—ฌ ์žฌ์ƒํ•˜๊ณ  ์žˆ๋Š”๋ฐ, play()๋Š” ์ œ๋Œ€๋กœ ํ˜ธ์ถœํ•˜๊ณ  ์žˆ์œผ๋‚˜ waitingToPlayAtSpecifiedRate์—์„œ playing์œผ๋กœ ๋„˜์–ด๊ฐ€์ง€ ์•Š๊ณ  ๋ฌดํ•œ ๋กœ๋”ฉ์ด ๊ฑธ๋ฆฌ๋Š” ๋ฌธ์ œ ํ•ด๊ฒฐ

 

## ๊ณ ๋ฏผํ•œ ์  / ํ•ด๊ฒฐ ๋ฐฉ๋ฒ•

> ๋น„๋””์˜ค ์ŠคํŠธ๋ฆฌ๋ฐ์„ ์žฌ์ƒํ•˜๋Š” ์…€์ด ์ปฌ๋ ‰์…˜๋ทฐ ๋ฆฌ๋กœ๋“œ๋ฅผ ํ•  ๋•Œ, ์žฌ์ƒํ•˜๋˜๊ฑธ ๋ฉˆ์ถ”๊ณ  ์…€์„ ๋ชจ๋‘ ๋ฆฌ์…‹ํ•œ ๋‹ค์Œ ๋‹ค์‹œ ๋ฐ์ดํ„ฐ๊ฐ€ ์„ค์ •๋˜๋ฉด์„œ ๋น„๋””์˜ค ์ŠคํŠธ๋ฆฌ๋ฐ์„ ์žฌ์ƒํ•ด์•ผํ•˜๋Š”๋ฐ, ๋ช‡๊ฐœ์˜ ์…€๋“ค์ด ๊ฐ„ํ—์ ์œผ๋กœ ์žฌ์ƒ๋˜์ง€ ์•Š๋Š” ๋ฌธ์ œ๊ฐ€ ๋ฐœ์ƒํ•˜์—ฌ ์ด๋ฅผ ํ•ด๊ฒฐํ•ด๋ณด์•˜๋‹ค.
์ฒ˜์Œ์—” ๋น„๋””์˜ค๋ฅผ ์ž๋™ ์žฌ์ƒ์„ ํ•˜๋Š” ๋กœ์ง์ด๋‚˜ ์žฌ์ƒํ•˜๋Š” ์‹œ์  ๋กœ์ง์— ๋ฌธ์ œ๊ฐ€ ์ƒ๊ฒจ ์‚ฌ์ด๋“œ ์ดํŽ™ํŠธ๊ฐ€ ์ผ์–ด๋‚˜๋Š” ์ค„ ์•Œ์•˜๋‹ค.
ํ•˜์ง€๋งŒ ๋””๋ฒ„๊น… ํ•ด๋ณด๋‹ˆ ๋กœ์ง์—๋Š” ๋ฌธ์ œ๊ฐ€ ์—†์—ˆ๊ณ  ์ •์ƒ์ ์œผ๋กœ `AVPlayer์˜` `play()` ๋ฉ”์†Œ๋“œ๋Š” ์ œ๋Œ€๋กœ ํ˜ธ์ถœ๋˜๊ณ  ์žˆ์—ˆ๋‹ค.

๊ทธ๋ž˜์„œ AVPlayer์˜ `timeControlStatus`, `reasonForWaitingToPlay๋ฅผ` ๊ด€์ฐฐํ•ด๋ณด์•˜๋‹ค.
* `timeControlStatus๊ฐ€` `waitingToPlayAtSpecifiedRate`์—์„œ `playing`์œผ๋กœ ๋ฐ”๋€Œ์–ด์•ผํ•˜๋Š”๋ฐ, ๊ฐ„ํ—์ ์œผ๋กœ ๋ฐ”๋€Œ์ง€ ์•Š๊ณ  ๊ณ„์† `waitingToPlayAtSpecifiedRate` ์ƒํƒœ์ธ ์ฑ„๋กœ ๋ฉˆ์ถฐ์„œ ์žฌ์ƒ์„ ํ•˜์ง€ ์•Š๋Š” ๊ฒƒ ๊ฐ™์•˜๋‹ค.
* ์ด๋•Œ `reasonForWaitingToPlay๋ฅผ` ์ถ”๊ฐ€๋กœ ๊ด€์ฐฐํ•ด๋ณด๋‹ˆ `evaluatingBufferingRate์—์„œ` ๋ฉˆ์ถฐ์„œ ๋”์ด์ƒ ์ƒํƒœ๊ฐ€ ๋ฐ”๋€Œ์ง€ ์•Š์•˜๋‹ค.

๊ทธ๋ž˜์„œ ๊ตฌ๊ธ€๋ง์„ ํ•ด๋ณด์•˜๋Š”๋ฐ... AVPlayer์˜ ์ž์ฒด์ ์ธ ๋ฒ„๊ทธ์ธ ๊ฒƒ ๊ฐ™์•˜๋‹ค. ๋น„์Šทํ•œ ํ˜„์ƒ์„ ๊ฒช๋Š” stackoverflow ๊ธ€๋“ค์ด ๋ช‡๊ฐœ๊ฐ€ ์กด์žฌํ–ˆ๋‹ค.
* ios avplayer indefinite waitingToPlayAtSpecifiedRate

๊ทธ๋ž˜์„œ `play()` ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœํ•˜๊ธฐ ์ „์— ์•„๋ž˜์™€ ๊ฐ™์ด ๋กœ์ง์„ ์ˆ˜์ •ํ•˜์˜€๋‹ค.
* `AVPlayerItem`์„ ๋‹ค์‹œ ์ดˆ๊ธฐํ™”ํ•œ๋‹ค.
* `replaceCurrentItem(with:)` ๋ฉ”์†Œ๋“œ๋ฅผ ์žฌํ˜ธ์ถœ์‹œ์ผœ์ค€๋‹ค.

์ผ๋‹จ ๋ฌธ์ œ๋˜์—ˆ๋˜ ๋ฌดํ•œ๋กœ๋”ฉ ํ˜„์ƒ์€ ์‚ฌ๋ผ์กŒ์ง€๋งŒ, ๊ฐ„ํ—์ ์ธ ํ˜„์ƒ์ด์˜€๋˜์ง€๋ผ ์ด๊ฒŒ ์ •ํ™•ํ•œ ์›์ธ์ธ์ง€๋Š” ์ž˜ ํŒŒ์•…์ด ๋˜์ง„ ์•Š๋Š”๋‹ค.
ํ•˜์ง€๋งŒ ์ผ๋‹จ ์˜ค๋Š˜ ํ…Œ์ŠคํŠธํ•ด๋ณด์•˜์„ ๋•Œ, ๋”์ด์ƒ ๋น„๋””์˜ค๊ฐ€ ์žฌ์ƒ๋˜์ง€ ์•Š๋Š” ํ˜„์ƒ์€ ์‚ฌ๋ผ์ ธ์„œ ์ด๊ฑธ๋กœ ๋งˆ๋ฌด๋ฆฌํ•˜๊ธฐ๋กœ ํ–ˆ๋‹ค!

---

- ์ฐธ๊ณ ๋งํฌ
- https://stackoverflow.com/questions/36858988/avplayer-does-not-fire-playbackbufferempty-but-does-not-play-either
- https://developer.apple.com/documentation/avfoundation/avplayer/timecontrolstatus/waitingtoplayatspecifiedrate
- https://developer.apple.com/documentation/avfoundation/avplayer/waitingreason/1643489-evaluatingbufferingrate

0 comments on commit 6f3dfe7

Please sign in to comment.