Android Question Had to reinstall my modified Audio.xml with b4a v 3.8

GuyBooth

Active Member
Licensed User
Longtime User
After I installed the 3.8 beta I had to reinstall my modified Audio.xml file. I'm not surprised, but is it possible to include the modification in future versions of b4a?

This is to make it possible to get and set the position in an audio stream in the MediaPlayerStream object, which works when modified according to this thread:

http://www.b4x.com/android/forum/threads/mediaplayerstream-seekto-and-getcurrentposition.39819/

Note that the "modified" Audio.xml file that was attached had NOT actually been modified - you have to follow the instructions to insert the code right after the Duration Property in the MediaPlayerStream wrapper area of the Audio.xml file:

B4X:
 <property>
            <name>Position</name>
            <returntype>int</returntype>
            <parameter>
                <name>v</name>
                <type>int</type>
            </parameter>
            <comment>Gets or sets the playing position (in milliseconds).</comment>
        </property>

Would be great if it was there for everyone to use.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
The reason that this property was hidden is that it didn't work in almost all cases.

You can easily call it with JavaObject:
B4X:
Sub GetPosition(mps As MediaPlayerStream) As Int
 Dim jo As JavaObject = mps
 Return jo.RunMethod("getPosition", null)
End Sub

Sub SetPosition(mps As MediaPlayerStream, Position As Int)
 Dim jo As JavaObject = mps
 jo.RunMethod("setPosition", Array (Position))
End Sub
 
Upvote 0

GuyBooth

Active Member
Licensed User
Longtime User

Thanks Erel. My first attempt using this approach hadn't been successful, but I have made it work now so I can go back to using the unmodified Audio.xml file.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…