Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Native Development

Reply
New Developer
avitat
Posts: 18
Registered: ‎01-22-2010
My Device: BB 9000
My Carrier: Rogers

Encoding bug with QUrl

[ Edited ]

I've found what I believe is a bug in QUrl. It encodes characters in the URL unecessarily. In the samples below I removed most of the URL because the problem occurs in the signature param.

 

The URL as provided by my server contains a signature param that looks like:

Signature=SR31T0%2FARELE8uKXBwBayLrHmLk%3D

 

As you can see the / and = characters are already encoded as percent hex values. If pass this in the URL as a string to QUrl it re-encodes the % again to yield %252F and %253D

 

I thought I could work around this by creating the QUrl object using QUrl::fromEncodedUrl(). That yields the original unencoded URL, but when I pass this to MediaPlayer it eventually becomes double encode again as you can see in the trace below:

 

The URL shown after play: is what I'm passing to MediaPlayer.sourceURL()

 

play:http://s3.amazonaws.com/irrelevant_url_stuff&Expires=1358287835&Signature=SR31T0/ARELE8uKXBwBayLrHmL...
START 1 MediaPlayer::setSourceUrl 
MediaPlayer::setSourceUrl: url=QUrl("http://s3.amazonaws.com/irrelevant_url_stuff&Expires=1358287835&Signature=SR31T0%2FARELE8uKXBwBayLrH...") 
START 1 MediaPlayerPrivate::detachInput 
START 1 MediaPlayerPrivate::setMediaState 
MediaPlayerPrivate::setMediaState: Attempting to change to same state.  mediaState=Unprepared
=> END 1 ( 1 ms): 
=> END 1 ( 2 ms): 
START 1 MediaPlayerPrivate::setMediaState 
MediaPlayerPrivate::setMediaState: Attempting to change to same state.  mediaState=Unprepared
=> END 1 ( 1 ms): 
MediaPlayer::setSourceUrl: emit sourceChanged()
MediaPlayer::setSourceUrl:   url=QUrl("http://s3.amazonaws.com/irrelevant_url_stuff&Expires=1358287835&Signature=SR31T0%2FARELE8uKXBwBayLrH...") 
=> END 1 ( 5 ms): 
START 1 MediaPlayer::play 
START 1 MediaPlayer::prepare 
START 1 MediaPlayerPrivate::generateAudioOutputUrl 
MediaPlayerPrivate::generateAudioOutputUrl: audioOutput=Default
=> END 1 ( 1 ms): 
START 1 MediaPlayerPrivate::generateVideoOutputUrl 
MediaPlayerPrivate::generateVideoOutputUrl: videoOutput=None
MediaPlayerPrivate::generateVideoOutputUrl: windowId=""
MediaPlayerPrivate::generateVideoOutputUrl: windowGroupId=""
=> END 1 ( 3 ms): 
Unrecognized scheme "http" 
START 1 MediaPlayerPrivate::updateAudioOutputParams 
=> END 1 ( 1 ms): 
START 1 MediaPlayerPrivate::lastError 
=> END 1 ( 0 ms): 
MediaPlayer::prepare: Error attaching input source. url="http://s3.amazonaws.com/irrelevant_url_stuff&Expires=1358287835&Signature=SR31T0%252FARELE8uKXBwBayL...", error=SourceUnavailable
=> END 1 ( 174 ms): 
MediaPlayer::play: Unable to prepare the player
=> END 1 ( 176 ms):

 

Please use plain text.
Developer
kunal_one
Posts: 145
Registered: ‎12-23-2012
My Device: BB10 Dev Alpha
My Carrier: wifi

Re: Encoding bug with QUrl

if your URL is already encoded then you need to you 

 

QUrl::fromEncoded() API.

QUrl url = QUrl::fromEncoded("http://qt.nokia.com/List%20of%20holidays.xml");

 

If only portion of url fragment is encoded the you need to add that using 

QUrl::addEncodedQueryItem

Please use plain text.
New Developer
avitat
Posts: 18
Registered: ‎01-22-2010
My Device: BB 9000
My Carrier: Rogers

Re: Encoding bug with QUrl

The second encoding is happening inside the MediaPlayer. It shouldn't be encoding at all.

Please use plain text.
Developer
hakimrie
Posts: 82
Registered: ‎07-23-2009
My Device: 9900
My Carrier: XL

Re: Encoding bug with QUrl

[ Edited ]

how about using parsingMode StrictMode

 

QUrl("audiopath", QUrl::StrictMode);

 

Please use plain text.
New Developer
NH_dev
Posts: 6
Registered: ‎02-09-2013
My Device: BlackBerry Z10
My Carrier: VivaCell

Re: Encoding bug with QUrl

[ Edited ]

Hi Guys,

 

any update on this ? I'm having the same problem, and can't find a workaround.

 

The worst thing is that mediaPlayer is doing partial encoding (e.g. %2 - %252 ), and when the URL is completely decoded, it does not encode it.

 

Please suggest.

 

      Narek

Please use plain text.