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

Java Development

Reply
Contributor
papdoligosa
Posts: 27
Registered: ‎02-12-2010
My Device: Torch 9800

How To Get the Current Time Index Using PlayerListener.playerUpdate

According to the article Everything You Want To Know About Multimedia, But Don't, the undocumented Player event com.rim.timeUpdate comes with an eventData as a Long object designating the current time index (in millis) of the media being played.

 

But when I try to get the eventData, I get an instance of an internal class net.rim.device.internal.media.PlayerImpl$MediaTimeEvent instead of a Long.

 

Since PlayerImpl$MediaTimeEvent is internal, I cannot process this object. Is there another way to get the current time of the media using the PlayerListener.playerUpdate(Player, String, Object) method?

 

Thanks!

Retired
Retired
BVP
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified

Re: How To Get the Current Time Index Using PlayerListener.playerUpdate

Hi papdoligosa!

 

I have to apologize, it *used* to return a Long value, it now returns an internal MediaTimeEvent instance which as you can see you don't have access to.  I have updated the documentation which will show up on the public page shortly.  Again, I apologize for the error.

 

The event is sent every second so it can still be used for example to implement a seek-bar or timer, as long as you know the duration of the media.  Between that and Player.getMediaTime you should be able to implement all of the functionality that knowing the time in this event would tell you.  Specifically, getMediaTime can tell you where you end up after a seek(), so you can set your UI - seek-bar or timer - accordingly.

 

BVP

New Developer
ajibz
Posts: 13
Registered: ‎04-01-2012
My Device: 9630

Re: How To Get the Current Time Index Using PlayerListener.playerUpdate

 

Hi BVP,

 

You stated that as long as you know the duration of the media, i am trying to get the duration of an MP4 file from the file header, but no luck so far. All the information i have see is for Java SE, any pointers on how to get this done?

 

Thanks,

Jibola

Retired
Retired
BVP
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified

Re: How To Get the Current Time Index Using PlayerListener.playerUpdate

[ Edited ]

Hi Jibola!

 

The Player class getDuration() method can be used.  The Player may need to be prefetched (not just realized) to return a valid value but I'm not 100% sure.  It's been quite some time since I've been working with BlackBerry OS 7 so you'll have to try it out to check which state it needs to be in :smileyhappy:

 

BVP

New Developer
ajibz
Posts: 13
Registered: ‎04-01-2012
My Device: 9630

Re: How To Get the Current Time Index Using PlayerListener.playerUpdate

Hi BVP,

 

thanks for your response, i have tested it out. The problem is that i am fetching an MP4 file from an InputStream of a HttpConnection, simulating a streaming url, the getDuration() returns -1. Any other pointers?

 

Thanks,

Jibola

Retired
Retired
BVP
Posts: 150
Registered: ‎10-19-2010
My Device: Not Specified

Re: How To Get the Current Time Index Using PlayerListener.playerUpdate

Hmmmm... the HttpConnection has a getLength() which returns the length of the data from the HTTP header, that's not terribly useful as it's the length of the data and container not of the media time.  Other than parsing the mp4 data to get the length yourself, I can't think of any other options off-hand...

 

BVP

New Developer
ajibz
Posts: 13
Registered: ‎04-01-2012
My Device: 9630

Re: How To Get the Current Time Index Using PlayerListener.playerUpdate

i agree, can i get any pointers on parsing the mp4 data, it has been difficult getting proper documentation online. The content length returns -1, which i guess means the web server is not returning the content length.

 

thanks.