Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84585

QMediaPlayer fails to play media from resource when app name has spaces

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • 5.15.1
    • 5.15.0
    • Multimedia
    • None
    • macOS Catalina 10.15.4, Xcode 11.5
    • macOS
    • 9c16be3d9d956f612dda431f4883eab3b09a8b67 (qt/qtmultimedia/dev) d6076e0963b16ec98c13ce126db1d94a8f2952ca (qt/qtmultimedia/5.15)

    Description

      QMediaPlayer fails to play media from built-in resource when app name has spaces:

      QApplication::setApplicationName("App Name");

      this is happens due to space character passed to NSURL.

      any Qt below 5.15 is not affected. bug appeared only with Qt 5.15

      for example, Qt 5.12.8 uses QUrl.toEncoded() before creating of NSURL:

      https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm?h=v5.12.8#n529

      //Load AVURLAsset
      //initialize asset using content's URL
      NSString *urlString = [NSString stringWithUTF8String:content.canonicalUrl().toEncoded().constData()];
      NSURL *url = [NSURL URLWithString:urlString];
      [(AVFMediaPlayerSessionObserver*)m_observer setURL:url];

      but Qt 5.15 uses QUrl.toString(), which has different behavior:

      https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm?h=v5.15.0#n595

      //Load AVURLAsset
      //initialize asset using content's URL
      setURL(m_observer, m_resources.request().url().toString());

      https://code.qt.io/cgit/qt/qtmultimedia.git/tree/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm?h=v5.15.0#n543

      static void setURL(void *observer, const QString &url, const QString &mimeType = QString())
      {
          NSString *urlString = [NSString stringWithUTF8String:url.toUtf8().constData()];
          NSURL *nsurl = [NSURL URLWithString:urlString];
          [static_cast<AVFMediaPlayerSessionObserver*>(observer) setURL:nsurl mimeType:[NSString stringWithUTF8String:mimeType.toLatin1().constData()]];
      }
      

      and as result invalid URL like that for temporary file is generated, and later passed to AVFMediaPlayerSessionObserver.

      file:///private/var/folders/6t/zk9vl9js75d6lh4921f4xytr0000gn/T/App Name.aoeRPH.wav

      AVPlayer remains in unknown state because

      AVFMediaPlayerSession::processLoadStateChange() 

      is NOT called at all.

       

      QMediaPlayer::mediaStatus() reports QMediaPlayer::LoadingMedia and QMediaPlayer::LoadedMedia is never happen

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              valentyn.doroshchuk Valentyn Doroshchuk
              nick-korotysh Nick Korotysh
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes