Android Question MediaPlayerStream Duration not working

shashkiranr

Active Member
Licensed User
Longtime User
Hi,

MediaPlayerStream duration is not working for the following mp3 file.

B4X:
"http://rekard.com/abhyas/tracks/5_Rangana_Nodire_Sushrutha/Without_metronome/Rangana_Nodire_120_C.mp3"

1. Is there a problem with the Mp3 file?

2. Since the duration is coming 0 is there any other way i can get the duration?

3. I am using
B4X:
Dim s As String
    Dim r As Reflector
    r.Target = s
    r.RunPublicmethod("setDataSource",Array As Object("http://rekard.com/abhyas/tracks/5_Rangana_Nodire_Sushrutha/Without_metronome/Rangana_Nodire_120_C.mp3"), Array As String("java.lang.String"))

s = r.RunPublicmethod("extractMetadata",Array As Object("METADATA_KEY_DURATION"), Array As String("java.lang.int"))
    Log("Meta data duration"&s)
But im getting no such method found. how to get the metadata duration.

Kindly let me know your suggestions and inputs.

Regards,
SK
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Seems like the duration is not available in this case:
B4X:
Dim jo As JavaObject
jo.InitializeNewInstance("android.media.MediaMetadataRetriever", Null)
Dim m As Map
m.Initialize
jo.RunMethod("setDataSource", _
   Array As Object("http://rekard.com/abhyas/tracks/5_Rangana_Nodire_Sushrutha/Without_metronome/Rangana_Nodire_120_C.mp3", _
     m))
Log(jo.RunMethod("extractMetadata", Array As Object(9))) 'duration constant
It returns 0.
 
Upvote 0
Top