QtAV icon indicating copy to clipboard operation
QtAV copied to clipboard

QMLPlayer and the QML controls have problems with percent encoded URL's

Open paul-h opened this issue 10 years ago • 7 comments

It seems something on the QML side of things is mangling URLs passed to the player. An example URL is http://192.168.1.204:55555/BBC%20ONE%20N%20West

"Player http://192.168.1.204:55555/BBC%20ONE%20N%20West" will work fine.

But try "QMLPlayer http://192.168.1.204:55555/BBC%20ONE%20N%20West" and you get a 404 not found.

You get the same problem when setting the 'source' property of any of the QML controls as well.

paul-h avatar May 10 '16 20:05 paul-h

In QML, source is a QUrl. Seems Qt decode the url first, then the url passed to player is http://192.168.1.204:55555/BBC ONE N West. So you can encode the url first.

wang-bin avatar May 11 '16 03:05 wang-bin

OK thanks that works :)

For anyone who comes across this in the future you need to do something like this if you want to pass a percent encoded URL. source: encodeURI("http://192.168.1.204:55555/BBC%20ONE%20N%20West");

Personally I think the behaviour should be consistent with all the other players I tried including the C++ Player and just accept the URL as is but having to encode the URL first is an easy work around.

paul-h avatar May 11 '16 09:05 paul-h

This is a bug! If you use default Image element of QtQuick, you can use source as this: source: "http://192.168.1.200/Image/logo (copy).png" and it works fine! but in QMLPlayer source must be as following to works correct: source: decodeURI(decodeURI("http://192.168.1.200/Video/aammaamme (copy).mp4")); This is double! I noticed that URL changed to path and result passed to mpPlayer object (in QmlPlayerAV.cpp file). This should works by URL transparently as Qt. Please reopen this issue. Thanks

seyedmmousavi avatar Jul 07 '16 18:07 seyedmmousavi

@seyedmmousavi How can I reproduce it? Why you call decodeURI twice? The original url works.

wang-bin avatar Jul 08 '16 02:07 wang-bin

excuse me. It must be encodeURI not decodeURI. You can reproduce it as following: -upload a video file into any http web server. change its name as aammaamme 1 2 3.mp4 with some space characters within it. -open QMLPlayer example of the QtAV source code -open main.qml file -change value of source property of the player element to targeting your uploaded video as source: encodeURI(encodeURI("http://192.168.42.197/aammaamme (copy).mp4")) -run application!

PLEASE NOTE: -above sample video has some spaces characters. so you need to encode it. but in default Image element of the QtQuick you don't need to do it manually and it will be done internally. -@paul-h has a url which already encoded and he needs to encode it again! (source: encodeURI("http://192.168.1.204:55555/BBC%20ONE%20N%20West");)

seyedmmousavi avatar Jul 09 '16 13:07 seyedmmousavi

@seyedmmousavi You are right. Thanks. Please try the latest code.

wang-bin avatar Jul 09 '16 16:07 wang-bin

Good news! Thank you man 👍

seyedmmousavi avatar Jul 12 '16 13:07 seyedmmousavi