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
Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10

MediaPlayer object on 10.1

Hi,

 

Is there something wrong in the following snippet code?:

 

		bps_initialize();
MediaPlayer* mp = new MediaPlayer();			
mp->setSourceUrl(QUrl("http://76.73.4.30:80"));
			if (mp->play() != MediaError::None) { //doesn't play
				result["result"] = "error";
				result["error"] = mp->mediaError();
			}
			else{//started playing
				result["result"] = "playing";
			}

 The compiler signals no errors and it was working fine on 10.0 but on 10.1 it just enters in the error branch. The url is for a streaming media such as mp3 and is online.

 

I use this in a custom webworks extension.

BlackBerry Development Advisor
smcveigh
Posts: 668
Registered: ‎11-29-2011
My Device: developer

Re: MediaPlayer object on 10.1

maybe you could post what the error string is?

New Contributor
mvaranda
Posts: 9
Registered: ‎04-25-2013
My Device: Z10

Re: MediaPlayer object on 10.1

Maybe it is missing the "document" you want to play:

"http://76.73.4.30:80/something.mp4"

New Contributor
mvaranda
Posts: 9
Registered: ‎04-25-2013
My Device: Z10

Re: MediaPlayer object on 10.1

OK... the original link points to an old SHOUTcast version: "SHOUTcast Distributed Network Audio Server/Linux v1.9.8"

This version SHOUTcast server does not support HTTP Range request properlly.

Try a link using SHOUTcast >= v2.2.0.92

 

ex: http://stream-10.shoutcast.com:80/smoothjazz_skyfm_mp3_96kbps

 

Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10

Re: MediaPlayer object on 10.1

[ Edited ]

The strange thing is that the last error code contained by the mp object is "0" which means no error, if no internet connection is available, meaning that the rest of the code is fine.

 

If I turn on wifi, the app simply crashes after a few seconds after I send the url to the extension.

 

Also, this exact same code worked fine in 10.0, I didn't find any changelog regarding the MediaPlayer object in 10.1

 

I also tried using a URL like this "http://ice.stream.frequence3.net/frequence3-128.mp3" still nothing, the "http://stream-10.shoutcast.com:80/smoothjazz_skyfm_mp3_96kbps" doesn't work either.

 

Maybe it would help if there would be some kind of changelog regarding this object or maybe there's an unoticed bug on 10.1, considering that this code worked perfectly before with any kind of shoutcast/iceast stream.

 

New Contributor
mvaranda
Posts: 9
Registered: ‎04-25-2013
My Device: Z10

Re: MediaPlayer object on 10.1

SW dev nowadays is like: you spend a month creating a feature following the specs. Then you spend other 24 months working around bugs of others who did not followed the specs.

 

10.0 had a work around to support old SHOUTcast servers. The work around had a side effect for some other more important media (live TV) when working under some buggy HTTP proxies for some US carriers. So 10.1 had to have the SHOUTcast  work around for old servers removed. 

 

Does the suggested link work when you open it using the browser? It does work fine for me on my Z10.

Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10

Re: MediaPlayer object on 10.1

Hi,

Yes I can play http://76.73.4.30/; and http://stream-10.shoutcast.com/smoothjazz_skyfm_mp3_96kbps in the browser, so I quess I can get them playing using audio tag, but these are mp3 streams, which I could already get them playing using a flash player if everything else failed, like I did on PlayBook. The beauty of BB10 was this awesome C++ extension which I could use to play any stream using that convenient MediaPlayer object..

 

The problem is that 90% of all online radios use ShoutCast 1.9.8. The removal of that workaround in 10.0 may break many apps when 10.1 comes around. It should be kept and maybe only used via a special flag. 

 

Is there any other way I could get AAC and MP3 shoutcast streams to play? I read about mmr, is it any different than MediaPlayer object? I know it's a lot to ask, but if it's doable using mmr, is there any example/sample?

 

Anyway I'm facing a really hard time, with 10.1 just around the corner, everybody will update to it and my BFB app will be useless, not to mention the email complaints afterwards..

 

Thanks for your answers so far.

New Contributor
mvaranda
Posts: 9
Registered: ‎04-25-2013
My Device: Z10

Re: MediaPlayer object on 10.1

It seems that your original link works for 10.1 even having an old SHOULTcast server version if you set user agent to "NSPlayer/7.10.0.3059"

The server places a HTML doc for the default BB10 user agent rathen than a valid ICY stream.

 

I do not see a method in Cascades to set user agent but I believe that you can use mm-renderer C API (OPT_USERAGENT):

 

http://developer.blackberry.com/native/reference/bb10/mmrenderer_libref/topic/mmr_api/mmr_context_pa...

 

 

 

Regular Contributor
andreyavram
Posts: 76
Registered: ‎06-02-2012
My Device: Playbook, BB10

Re: MediaPlayer object on 10.1

ShoutCast servers can be forced to deliver the stream if ";" is appended to the url, then they won't show the html but directly the stream. However the MediaPlayer still can't handle it.

 

My C++ knowledge is very limited, would you care to show me your example or how did you tested? 

Thanks a lot! 

New Contributor
mvaranda
Posts: 9
Registered: ‎04-25-2013
My Device: Z10

Re: MediaPlayer object on 10.1

So "http://76.73.4.30:80/;" should work in your code.

I am not familiar with C++ API.

 

There is a sample code in GitHub. You may want to looks at that:

https://github.com/blackberry/NDK-Samples/tree/master/PlayAudio

 

I have not tried yet but it might help you. You should be able to mix C++ and C (replace MediaPlayer class by your own by wrapping the mm-renderer functions).