Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. How to get QMediaPlayer to play a network file on a Mac?

How to get QMediaPlayer to play a network file on a Mac?

Scheduled Pinned Locked Moved Unsolved Qt for Python
4 Posts 3 Posters 786 Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    donquibeats
    wrote on last edited by
    #1

    Hello

    I'm working on an application that will use a QMediaPlayer widget, and which will need to work on both PC and Mac.

    I have a series of UNC paths to video files that are stored on a server (the fact these are stored in Windows-style UNC paths is a legacy thing and can't be changed). They are of the format "\11.22.33.44\path\movie.mp4". I need to be able to get QMediaPlayer to open these files and play them from the server.

    On Windows, there's no problem- QMediaPlayer is playing the media files really nicely indeed, I'm very happy.

    However on Mac, I am hitting a "Failed to load media" message no matter what I try. I've tried various combinations of Samba prefixes, QUrl's setScheme method, and so on- but any path that involves an IP address is always hitting "Failed to load media", every time, with any path of a format like "smb://11.22.33..44/path/movie.mp4".

    If I use a QFileDialog and browse manually to the file, then the file will definitely play on a Mac. The QUrl then reports as "file:///Volumes/path/movie.mp4" and it plays fine. However I don't know how to translate a "smb://" path into a "file:///Volumes/" path, and as it stands I don't think it can be assumed that the drive will already be mounted.

    Please can someone give me a pointer on how to get a QMediaPlayer playing a remote file on a Mac?

    Thanks

    Stuart

    1 Reply Last reply
    0
    • D Offline
      D Offline
      donquibeats
      wrote on last edited by
      #2

      The QFileDialog is generating a path which QMediaPlayer will then read from, but only if I manually navigate to the file using a QFileDialog front-end and tell it exactly where it is.

      My problem is simpler and more fundamental than I first implied, and involves trying to convert a string "\11.22.33.44\path\movie.mp4" into a valid MacOS path that any function (e.g. shutil.copyfile) will accept.

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        Where do you get that string from ? Usually on *nix OSs all paths are using forward slashes.

        In any case, you have QDir::toNativeSeparators to get a path which can be passed to function expecting such a string.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        3
        • D Offline
          D Offline
          donquibeats
          wrote on last edited by
          #4

          Thanks for the response.

          The paths are from an existing piece of software which has stored the paths of lots of files as strings in a database. That existing software has been Windows-only for years so until now there was no issue with using UNC paths, but this new code I'm working on needs to be both Windows- and Mac-friendly, hence the UNC paths suddenly being a problem.

          In order to move something forward I'm now working on automatically mounting the required servers when needed. I don't know whether this is the only way to do it on a Mac for QMediaPlayer use, or whether this is a temporary workaround and there may be a better solution I haven't found yet.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved