[Interest] QVideoWidget Error: /Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display <n>

Byron Formwalt byron at fastmail.net
Sat Jul 8 07:26:36 CEST 2017


Configuration: PyQt 5.9 with Python 3.6.1 on macOS 10.12.5

Problem: I am evaluating PyQt as a means of playing back videos within a UI.  I am including a simple Python script that reproduces the following three problems:

  1. When the video plays back it is not scaled to fit the widget.  Instead, the pixel ration is set 1:1 and playback is clipped accordingly by the bounds of the QVideoWidget.  When the window is resized, the video does get rescaled.  

  2. When the window is set to full-screen mode, playback is blocked unless the user moves the mouse into the menubar or exits full screen mode.

  3. The following error appears almost immediately after playback begins:  "/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 4”

Discussion:  I am writing to see if other users have experienced this issue, and if so, has anyone discovered a remedy?

Source:
#!/usr/bin/env python3

from PyQt5.QtCore import *
from PyQt5.QtMultimedia import *
from PyQt5.QtMultimediaWidgets import *
from PyQt5.QtWidgets import *
import sys
import os


def handle_error(mp,e):
    print("Error!: {} ({})".format(mp.errorString(),e))

def state_changed(mp,s):
    if s == QMediaPlayer.StoppedState:
        state = "Stopped"
        mp.setPosition(0) # Set playback position in ms since the beginning.
        mp.play()
    elif s == QMediaPlayer.PlayingState:
        state = "Playing"
    elif s == QMediaPlayer.PausedState:
        state = "Paused"
    else:
        state = "Unknown"
    print("Media player state changed to: {} (mp.state() -> {})".format(state,mp.state()))


if __name__ == '__main__':
    app = QApplication(sys.argv)

    video_path = os.path.join(os.environ['HOME'],'Movies')
    video_name = 'test.mp4'
    
    video_pathname = os.path.join(video_path,video_name)
    print("Loading Video: {}".format(video_pathname))
    layout = QVBoxLayout()

    vw = QVideoWidget()
    mp = QMediaPlayer()
    mp.error.connect(lambda e: handle_error(mp,e))
    mp.stateChanged.connect(lambda s: state_changed(mp,s))
    mp.setVideoOutput(vw)
    mp.setMedia(QMediaContent(QUrl("file://"+video_pathname)))

    window = QMainWindow()
    window.setCentralWidget(vw)
    window.show()

    mp.play()
    app.exec_()
Relevant Output:
Media player state changed to: Playing (mp.state() -> 1)
/Library/Caches/com.apple.xbs/Sources/AppleGVA/AppleGVA-10.1.16/Sources/Slices/Driver/AVD_loader.cpp: failed to get a service for display 4 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20170707/f6cde97f/attachment.html>


More information about the Interest mailing list