Playing Video into UITableView

前端 未结 3 1530
别那么骄傲
别那么骄傲 2020-12-08 17:32

I have read several posts here about live streaming video/audio. Unfortunately it seems that there is not any \"good\" solution.

I want same functionali

3条回答
  •  南方客
    南方客 (楼主)
    2020-12-08 17:51

    Don't use MPMoviePlayerController, use AVFoundation's AVPlayer.

    Additionally, don't couple the downloading of your asset to your UITableViewCell subclass. Use an additional data source to download and manage the video assets.

    There are a few ways you can do this.

    1. Keep a data source array of AVPlayerItem objects initialized by URL. Instead of loading the asset each time you scroll to a cell, just load the AVPlayerItem into the cell's player, and remove it when you scroll away.

    2. If you need to persist the video data, consider downloading each video to a temporary file in your Documents directory. When the file has finished downloading, load that data into an AVAsset using its initWithURL: method and point the URL to your local file. When ready, you can load your asset into an AVPlayerItem using initWithAsset: and play the video.

提交回复
热议问题