Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to escape curly brackets ('{}') in a Video 'source' property ?

How to escape curly brackets ('{}') in a Video 'source' property ?

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
7 Posts 2 Posters 2.3k 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
    Curtwagner1984
    wrote on last edited by
    #1

    Hello,
    I understand that this might be a trivial question, but I wasn't able to find a solution online.

    I have a 'Video' component that plays videos from the local file system. It works fine but when the path to the video contains curly brackets it fails with the following error:

    DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 (Unspecified error)

    and the 'status' of Video is MediaPlayer.InvalidMedia

    I tried to escape them using \ like so:

    popupVideo.source = source.replace(/\{/g,'\\{').replace(/\}/g,'\\}');
    
    

    I also tried:

    popupVideo.source = encodeURI(source);
    
    

    but it didn't work, and I get the same error.

    I must reiterate, files without curly brackets in their path play completely fine.

    Again, I apologize if my question is trivial.

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

      Hi,

      What is the exact path that is failing ?

      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
      0
      • C Offline
        C Offline
        Curtwagner1984
        wrote on last edited by
        #3

        @SGaist

        qml: Source:D:/kodi/movies/test/I'm_Sorry_For_What_I_Said_When_I_Was_Hungry_WEBRip_Crushdawg {fluffy}.mkv
        qml: Status changed triggered in popupVideo, Status is 2
        DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 (Unspecified error)
        qml: Status changed triggered in popupVideo, Status is 8

        In this specific case this is the path that doesn't work D:/kodi/movies/test/I'm_Sorry_For_What_I_Said_When_I_Was_Hungry_WEBRip_Crushdawg {fluffy}.mkv however I tried it with 5 or 6 other path that contain curly braces and the result is the same. (As I said before, paths without braces work fine)

        This is the function that sets the path for the video:

        function setupVideo(source) {
                    sceneViewPopup.open()
        //          console.log("Source:" + source.replace(/\{/g,'\\{').replace(/\}/g,'\\}'))
                    console.log("Source:" + source)
        //          popupVideo.source = source.replace(/\{/g,'\\{').replace(/\}/g,'\\}');
                    popupVideo.source = source ;
                    
                }
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Might be a silly question but are you using different video containers or is it only the Matroska based that are not working ?

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

          C 1 Reply Last reply
          1
          • SGaistS SGaist

            Might be a silly question but are you using different video containers or is it only the Matroska based that are not working ?

            C Offline
            C Offline
            Curtwagner1984
            wrote on last edited by
            #5

            @SGaist I've tested .mp4, .avi, .m4v, .flv with and without braces in the path the the results are consistent. No braces works fine, with braces does not work.

            Furthermore, I've tested the same file with and without braces in the path, with braces does not work, without braces it does.

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

              Ok, then you should check the bug report system to see if it's something known. If not please consider opening a new report providing a minimal compilable example as well as your system setup.

              Don't forget to mention that you tested that with different file format/container.

              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
              0
              • C Offline
                C Offline
                Curtwagner1984
                wrote on last edited by
                #7

                @SGaist
                Oh, you think it's a bug in QT?
                I thought it was a simple case of adding an escape sequence before the braces.

                I've made this example, which tries to play the same video file (copy pasted and renamed) one with braces and other without braces, I've add it to the bug report.

                import QtQuick 2.8
                import QtQuick.Controls 2.1
                import QtMultimedia 5.5
                
                ApplicationWindow {
                    visible: true
                    width: 640
                    height: 480
                    title: qsTr("Hello World")
                
                    Rectangle{
                        id:mainRect
                        anchors.fill: parent
                        color:"grey"
                
                
                
                        Video{
                            id:noBraces
                            property bool isPlaying: false
                            anchors.top: rowLayout.bottom
                            width: 100
                            height: 100
                            fillMode: VideoOutput.PreserveAspectFit
                            source: "D:/kodi/movies/test/fluffy no braces.mkv"
                
                            onStatusChanged: {
                                console.log("noBraces status changed: Status is " + status)
                            }
                        }
                
                        Button{
                            id:noBracesPlay
                            anchors.top: noBraces.bottom
                            anchors.horizontalCenter: noBraces.horizontalCenter
                            text:"Play No Braces"
                            onClicked: {
                                if (!noBraces.isPlaying){
                                    noBraces.play()
                                    noBraces.isPlaying = true;
                                }else{
                                    noBraces.stop()
                                    noBraces.isPlaying = false;
                                }
                
                
                            }
                        }
                
                
                        Video{
                            id:braces
                            property bool isPlaying: false
                            anchors.left: noBraces.right
                            anchors.verticalCenter: noBraces.verticalCenter
                            width: 100
                            height: 100
                            fillMode: VideoOutput.PreserveAspectFit
                            source: "D:/kodi/movies/test/{fluffy braces}.mkv"
                
                            onStatusChanged: {
                                console.log("braces status changed: Status is " + status)
                            }
                        }
                
                        Button{
                            id:bracesPlay
                            anchors.top: braces.bottom
                            anchors.horizontalCenter: braces.horizontalCenter
                            text:"Play Braces"
                            onClicked: {
                                if (!braces.isPlaying){
                                    braces.play()
                                    braces.isPlaying = true;
                                }else{
                                    braces.stop()
                                    braces.isPlaying = false;
                                }
                
                
                            }
                        }
                    }
                }
                
                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