0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

複数のAVPlayerが起動してしまう問題を解決

Posted at

AVPlayerを終了する時にplayer.replaceCurrentItem(with: nil)を設定する

import UIKit
import AVKit

class PlayerLayerVC: UIViewController {

    var playerLayer = AVPlayerLayer()
    var player : AVPlayer! = AVPlayer()

    override func viewDidDisappear(_ animated: Bool) {
        super.viewDidDisappear(animated)
        
        player.replaceCurrentItem(with: nil)
    }
}
0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?