Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log player error when encountered #686

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions Mixin/UserInterface/Controllers/Chat/Views/GalleryVideoView.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import UIKit
import AVFoundation
import MixinServices

final class GalleryVideoView: UIView, GalleryAnimatable {

Expand All @@ -22,6 +23,8 @@ final class GalleryVideoView: UIView, GalleryAnimatable {
}
}

private var playerStatusObserver: NSKeyValueObservation?

required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
prepare()
Expand Down Expand Up @@ -74,6 +77,15 @@ final class GalleryVideoView: UIView, GalleryAnimatable {
playerView.backgroundColor = .clear
playerView.layer.videoGravity = .resizeAspect
playerView.layer.player = player
playerStatusObserver = player.observe(\.status) { player, _ in
if player.status == .failed {
if let error = player.error {
Logger.write(error: error)
} else {
Logger.write(log: "[GalleryVideoView] Player reports failed but no error is provided")
}
}
}

contentView.addSubview(coverImageView)
contentView.addSubview(playerView)
Expand Down