MIssing VLCOpenGLES2VideoView in UNNotificationContentExtension's view
Hello. I want to express my deep gratitude to the authors of the VLC player for its great features and project support.
I integrated it into my project to work with RTSP streams, but I ran into a problem with outputting a video stream.
I am using Remote Push Notifications in my application. Also, to display content in notifications, I implemented the UNNotificationContentExtension protocol.
For notification, I created a ViewController and added an instance of VLCMediaPlayer to it.
I have created a UIView and passed it to a drawable field.
When I receive a Push Notifiaction, I expand it on the device, the audio starts playing, but the video is not displayed.
I looked at the contents of the playerView(View on which the view should be displayed) after executing the mediaPlayerTimeChanged
method. playerView.subviews returned me an empty array.
Using the player in the normal screen (not in the notification) there was always an instance of VLCOpenGLES2VideoView
For tests, I used several versions of the library - 3.3.17, 3.4.0, 3.5.0. The problem was reproduced on all versions. There were no warnings or errors in the console.
I also tried version "4.0.0a1". On it, the result was the same, but in the console I saw many of the following errors:
[000000028059ebe0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028059ab20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028059ab20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028059ebe0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028059ab20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000016c216cb0] http generic error: local stream 1 error: Cancellation (0x8) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c10adf0] http generic error: local stream 1 error: Stream closed (0x5) [000000016c216cb0] http generic error: local stream 3 error: Cancellation (0x8) [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [0000000109827800] libvlc decoder error: buffer deadlock prevented [000000028059df20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028059df20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058eac0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058b5a0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058b600] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028058b600] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [0000000280595620] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058eac0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058eac0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028058eac0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058b1e0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028058b180] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028058f060] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028059ab20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028059adc0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028059df20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [000000028059df20] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed [0000000109827800] libvlc decoder: Using Video Toolbox to decode 'h264' [000000028059aca0] libvlc gl error: Creating OpenGL ES 2 view failed [000000010981c000] libvlc video output error: video output display creation failed
I tried to replace the rtsp stream with a regular mp4 file, but the result was the same. By replacing VLCMediaPlayer with the standard AVPlayerController the problem disappeared (I used an mp4 file). But AVPlayer cannot play RSTP streams. I tried all the ways that I found on the Internet, but nothing helped. How can this problem be solved ?
The implementation of the class for working with push notifications looks like this
class NotificationViewController: UIViewController, UNNotificationContentExtension {
// MARK: PARAMETERS
private lazy var player: VLCMediaPlayer = {
let player = VLCMediaPlayer()
player.delegate = self
return player
}()
// MARK: Views
// I have added playerView to view
@IBOutlet weak var playerView: UIView! // It does not matter how this view is created, creating it programmatically the result was the same
// MARK: UNNotificationContentExtension
func didReceive(_ notification: UNNotification) {
let content = notification.request.content.userInfo
guard
let streamRaw = userInfo["stream"] as? String,
let streamURL = URL(string: streamRaw)
else { return }
setupPlayer(with: streamURL)
}
// MARK: PRIVATE
private func setupPlayer(with url: URL) {
player.media = VLCMedia(url: url)
player.drawable = playerView
player.play()
}
}
extension NotificationViewController: VLCMediaPlayerDelegate {
func mediaPlayerTimeChanged(_ aNotification: Notification) {
print(playerView.subviews.count) // Always prints "0"
}
}