derez Expert Licensed User Longtime User Nov 6, 2016 #1 I'm trying to get a MP3 file's duration using the medialayer's method, but gets NaN : B4X: Dim uri As String = File.GetUri("E:\Music\Amit Erez","Please.mp3") mp.Initialize("mp",uri) mp.Play Log(mp.Duration) The file plays so the path is OK.
I'm trying to get a MP3 file's duration using the medialayer's method, but gets NaN : B4X: Dim uri As String = File.GetUri("E:\Music\Amit Erez","Please.mp3") mp.Initialize("mp",uri) mp.Play Log(mp.Duration) The file plays so the path is OK.
Daestrum Expert Licensed User Longtime User Nov 6, 2016 #2 You can try B4X: ... asJO(mp).RunMethodJO("getTotalDuration",null).RunMethod("toSeconds",null) ... Sub asJO(o as JavaObject) as JavaObject return o End Sub Also maybe try it before mp.play Last edited: Nov 7, 2016 Upvote 0
You can try B4X: ... asJO(mp).RunMethodJO("getTotalDuration",null).RunMethod("toSeconds",null) ... Sub asJO(o as JavaObject) as JavaObject return o End Sub Also maybe try it before mp.play
derez Expert Licensed User Longtime User Nov 7, 2016 #3 Daestrum said: You can try B4X: ... asJO(mp).RunMethodJO("getTotalDuration",null).RunMethod("toSeconds",null) ... Sub asJO(o as JavaObject) as JavaObject return o End Sub Also maybe try it before mp.play Click to expand... Thanks, it is the same. I tried with a Tag editor and I can see the time there... Last edited: Nov 7, 2016 Upvote 0
Daestrum said: You can try B4X: ... asJO(mp).RunMethodJO("getTotalDuration",null).RunMethod("toSeconds",null) ... Sub asJO(o as JavaObject) as JavaObject return o End Sub Also maybe try it before mp.play Click to expand... Thanks, it is the same. I tried with a Tag editor and I can see the time there...
Erel B4X founder Staff member Licensed User Longtime User Nov 7, 2016 #4 It will return the same result (in seconds instead of milliseconds) as the Duration property. Nan means that the duration is not yet known. You can use CallSubPlus to check the duration 100ms after you initialize mp. Upvote 0
It will return the same result (in seconds instead of milliseconds) as the Duration property. Nan means that the duration is not yet known. You can use CallSubPlus to check the duration 100ms after you initialize mp.
derez Expert Licensed User Longtime User Nov 7, 2016 #5 Erel said: It will return the same result (in seconds instead of milliseconds) as the Duration property. Nan means that the duration is not yet known. You can use CallSubPlus to check the duration 100ms after you initialize mp. Click to expand... Thank you, now I get it ! The min delay is 36 ms. Upvote 0
Erel said: It will return the same result (in seconds instead of milliseconds) as the Duration property. Nan means that the duration is not yet known. You can use CallSubPlus to check the duration 100ms after you initialize mp. Click to expand... Thank you, now I get it ! The min delay is 36 ms.