Android Question mediaplayer position

bijou

Member
Licensed User
Hi,
I am using the very usefull program posted in forum about media player to build a karaoke app with this using a variable as
B4X:
x=MediaPlayer1.Position
and then displaying Lyrics accordingly but now i have another issue, i don't know if this is because the app is getting heavy 5 to 6MB because of mp3 file or ... but the mediaplayer.position is now incrementing each 3 seconds not each second and this is making problem with displaying lyrics, any help please ???
 

bijou

Member
Licensed User
Are you using a timer to monitor the position?

i am using exactly the code you've posted in the forum and then to monitor the position i use just a variable, here is a small part of the code
B4X:
Sub timer1_Tick
    Resume.Enabled=False
    Resume.Visible=False
    Pause.Enabled=True
    Pause.Visible=True
    If MediaPlayer1.IsPlaying Then
        barPosition.Value = MediaPlayer1.Position / MediaPlayer1.Duration * 100
        lblPosition.Text = "Position: " & ConvertToTimeFormat(MediaPlayer1.Position) & _
            " (" & ConvertToTimeFormat(MediaPlayer1.Duration) & ")"
    End If
    x=MediaPlayer1.Position
    If x>=38*1000 And x<45*1000 Then
    Label2.Text="Ttxilek elli yi n tabburt a Vava Inuva a Vava Inuva"

I just did a test removing my mp3 files and just used one very small mid file from your example and got same problem !!!
 
Last edited:
Upvote 0

moster67

Expert
Licensed User
Longtime User
Is there still a delay if you remove the code which updates barPosition and the lblPosition?

B4X:
Sub timer1_Tick
    'this presumes that variable x has been declared
    'under Globals
    If MediaPlayer1.IsPlaying Then
        x=MediaPlayer1.Position
        If x>=38*1000 And x<45*1000 Then
            Label2.Text="Ttxilek elli yi n tabburt a Vava Inuva a Vava Inuva"
        End If
    End if
End sub

What is the interval value of your timer?
Do you start the timer when you start playing the mediafile?
 
Upvote 0

bijou

Member
Licensed User
Is there still a delay if you remove the code which updates barPosition and the lblPosition?
What is the interval value of your timer?
Do you start the timer when you start playing the mediafile?

Same problem, just finished testing your idea, yes the timer starts when the mediafile is playing, i think the interval value is in ms by default !
 
Upvote 0
Top