Skip to content

Latest commit

ย 

History

History
65 lines (48 loc) ยท 1.86 KB

File metadata and controls

65 lines (48 loc) ยท 1.86 KB

MusicPlayer Feature

K.K. Slider ์Œ์•… ์žฌ์ƒ๊ธฐ. ์ž์ฒด Coordinator๊ฐ€ ์—†๊ณ  AppCoordinator๊ฐ€ ์ง์ ‘ ๊ด€๋ฆฌ.

Structure

Presentation/MusicPlayer/
โ”œโ”€โ”€ PlayerMode.swift                    # minimize/maximize ๋ชจ๋“œ enum
โ”œโ”€โ”€ ViewControllers/
โ”‚   โ””โ”€โ”€ PlayerViewController.swift      # ํ”Œ๋ ˆ์ด์–ด UI
โ”œโ”€โ”€ ViewModels/
โ”‚   โ””โ”€โ”€ PlayerReactor.swift             # ์žฌ์ƒ ์ƒํƒœ ๊ด€๋ฆฌ
โ””โ”€โ”€ Views/
    โ”œโ”€โ”€ MaximizePlayerView.swift        # ํ™•์žฅ ๋ทฐ
    โ”œโ”€โ”€ MinimizePlayerView.swift        # ์ถ•์†Œ ๋ทฐ
    โ”œโ”€โ”€ SongRow.swift                   # ๋…ธ๋ž˜ ํ–‰
    โ””โ”€โ”€ SongRow.xib                     # XIB ๋ ˆ์ด์•„์›ƒ

AppCoordinator์—์„œ์˜ ๊ด€๋ฆฌ

AppCoordinator.swift๊ฐ€ PlayerViewController์˜ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ ์ง์ ‘ ์ œ์–ด:

// ํ‘œ์‹œ: ํƒญ๋ฐ” ์œ„ ์˜ค๋ฒ„๋ ˆ์ด๋กœ ์ถ”๊ฐ€
func showMusicPlayer()

// ์ถ•์†Œ: ํ•˜๋‹จ์— 80pt ๋ฏธ๋‹ˆ ํ”Œ๋ ˆ์ด์–ด
func minimize()

// ํ™•์žฅ: 450pt ํฐ ํ”Œ๋ ˆ์ด์–ด
func maximize()

// ์ œ๊ฑฐ
func removePlayerViewController()

PlayerViewController๋Š” ํƒญ๋ฐ” ์œ„์— addSubview๋กœ ๋ฐฐ์น˜. topAnchor constraint ์กฐ์ ˆ + spring animation์œผ๋กœ minimize/maximize ์ „ํ™˜.

Audio Engine: MusicPlayerManager

File: Utility/MusicPlayerManager.swift (์‹ฑ๊ธ€ํ†ค)

  • AVPlayer๋กœ ์˜ค๋””์˜ค ์žฌ์ƒ
  • BehaviorRelay๋กœ ์ƒํƒœ ๊ด€๋ฆฌ (isPlaying, currentSong, progress ๋“ฑ)
  • ๋ฐฑ๊ทธ๋ผ์šด๋“œ ์žฌ์ƒ ์ง€์›
  • MPRemoteCommandCenter ์—ฐ๋™ (์ž ๊ธˆํ™”๋ฉด ์ปจํŠธ๋กค)
  • ์žฌ์ƒ ๋ชจ๋“œ: shuffle, fullRepeat, oneSongRepeat

๋ฐ์ดํ„ฐ ํ๋ฆ„

Items.shared.categoryList[.songs] โ†’ MusicPlayerManager.shared.songList
    โ†“
PlayerReactor.mutate(.fetch) โ†’ Mutation.setSongs
    โ†“
PlayerViewController UI ์—…๋ฐ์ดํŠธ

์ฃผ์˜์‚ฌํ•ญ

  • ๋ณ„๋„ Coordinator๋ฅผ ๋งŒ๋“ค์ง€ ๋ง ๊ฒƒ โ†’ gotchas.md #10
  • PlayerReactor์˜ coordinator ํƒ€์ž…์€ AppCoordinator