Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. International
  3. Chinese
  4. Qt6.5 QMediaPlayer播放中文名媒体文件失败,如何处理?

Qt6.5 QMediaPlayer播放中文名媒体文件失败,如何处理?

Scheduled Pinned Locked Moved Unsolved Chinese
qmediaplayerqt6.5中文文件名
5 Posts 2 Posters 950 Views
  • 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.
  • C Offline
    C Offline
    cppdo
    wrote on 5 Jun 2023, 05:00 last edited by
    #1

    代码:

     QAudioDevice defaultDevice = QMediaDevices::defaultAudioOutput();
     QAudioOutput * audioOutput = new QAudioOutput(defaultDevice);
     audioOutput->setVolume (0.1);
     QMediaPlayer * player = new QMediaPlayer();
     player->setAudioOutput (audioOutput);
     player->setSource (QUrl ("/music/那些年.mp3"));
     player->play ();
    

    将文件名"那些年.mp3"改为"a.mp3"则播放成功

    1 Reply Last reply
    0
    • N Offline
      N Offline
      noexcept_zhao
      wrote on 5 Jun 2023, 14:26 last edited by
      #2

      应该是字符编码问题 解析的路径可能不对 试下用utf-8包字符串

      C 2 Replies Last reply 6 Jun 2023, 00:45
      0
      • N noexcept_zhao
        5 Jun 2023, 14:26

        应该是字符编码问题 解析的路径可能不对 试下用utf-8包字符串

        C Offline
        C Offline
        cppdo
        wrote on 6 Jun 2023, 00:45 last edited by cppdo 6 Jun 2023, 00:47
        #3

        @noexcept_zhao 搜索Qt论坛得到"QStringConverter"这个类, 按照官方帮助内容采用如下代码:
        filename="/music/那些年.mp3"
        auto utf8 = QStringDecoder(QStringDecoder::Utf8);
        QString utfStr = utf8(filename.toUtf8 ());
        //...
        player->setSource (QUrl (utfStr));
        然而并没有什么用.

        1 Reply Last reply
        0
        • N noexcept_zhao
          5 Jun 2023, 14:26

          应该是字符编码问题 解析的路径可能不对 试下用utf-8包字符串

          C Offline
          C Offline
          cppdo
          wrote on 6 Jun 2023, 02:21 last edited by
          #4

          @noexcept_zhao 有什么办法能准确的知道一个字符串的编码方式吗?

          1 Reply Last reply
          0
          • C Offline
            C Offline
            cppdo
            wrote on 19 Jun 2023, 08:37 last edited by
            #5

            这是Qt6.5的一个Bug.
            在官方Bug列表中以QMediaPlayer为关键字查询到Bug(QTBUG-112707).
            Fix playing of video files with Chinese names
            https://github.com/qt/qtmultimedia/commit/f1b07b9ac
            问题出现在 <Qt>\6.5.0\Src\qtmultimedia\src\plugins\multimedia\ffmpeg\playbackengine\qffmpegmediadataholder.cpp

            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