当我从互联网上加载视频(10-40MB大)时,我无法提供流畅的播放体验。
我的AVPlayer要么加载整个视频然后播放,要么播放1s缓冲区,然后停止播放。
我尝试了无穷无尽的库,缓冲区观察器方法和教程。似乎没有任何帮助。
Bitmap newImage = new Bitmap(file);
using (Graphics gr = Graphics.FromImage(newImage))
{
gr.InterpolationMode = InterpolationMode.HighQualityBicubic;
gr.PixelOffsetMode = PixelOffsetMode.HighQuality;
gr.DrawImage(newImage, 0, 0, newWidth, newHeight);
}
pictureBox1.Image.Dispose();
pictureBox1.Image = null;
pictureBox1.Refresh();
//pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBox1.Image = newImage;
}
答案 0 :(得分:7)
自 iOS 10.x 以来,您可以进行一些缓冲设置,例如,您可以决定缓存视频所需的秒数:
if #available(iOS 10.0, tvOS 10.0, OSX 10.12, *) {
avPlayer?.automaticallyWaitsToMinimizeStalling = .playWhenBufferNotEmpty
//preferredForwardBufferDuration -> default is 0, which means `AVPlayer` handle it independently, try more seconds like 5 or 10.
playerItem.preferredForwardBufferDuration = TimeInterval(5)
}