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

QMediaPlayer does not play local file with spaces in name

    XMLWordPrintable

Details

    • Bug
    • Resolution: Duplicate
    • P2: Important
    • None
    • 5.15.0
    • Multimedia
    • None
    • macOS 10.14.6 Mojave
    • macOS

    Description

      QMediaPlayer does not play a local file, if the name is including spaces.
      It was ok in Qt 5.14.2 and earlier.

      see
      qtmultimedia/src/plugins/avfoundation/mediaplayer/avfmediaplayersession.mm
      function setURL, Line 539

      1. Solution: using encoded URL

      539c539
      < static void setURL(void *observer, const QString &url, const QString &mimeType = QString())

      > static void setURL(void *observer, const QByteArray &url, const QString &mimeType = QString())
      541c541
      < NSString *urlString = [NSString stringWithUTF8String:url.toUtf8().constData()];

      > NSString *urlString = [NSString stringWithUTF8String:url.constData()];
      546c546
      < static void setStreamURL(void *observer, const QString &url)

      > static void setStreamURL(void *observer, const QByteArray &url)
      548c548
      < setURL(observer, QLatin1String("iodevice://") + url, QFileInfo(url).suffix());

      > setURL(observer, QByteArray("iodevice://") + url, QFileInfo(url).suffix());
      591c591
      < setStreamURL(m_observer, m_resources.request().url().toString());

      > setStreamURL(m_observer, m_resources.request().url().toEncoded());
      595c595
      < setURL(m_observer, m_resources.request().url().toString());

      > setURL(m_observer, m_resources.request().url().toEncoded());
      1040c1040
      < setStreamURL(m_observer, m_resources.request().url().toString());

      > setStreamURL(m_observer, m_resources.request().url().toEncoded());

       

      2. Solution

      Using NSURL:fileURLWithPath instead of NSURL:URLWithString for local files

      see Apples documentation

      https://developer.apple.com/documentation/foundation/nsurl/1572047-urlwithstring?language=objc

      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
              volkerh Volker Hemsen
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes