Android Question MediaPlayerStream not working on Android 9

Wolodymyr

Member
With my project I found, that MediaPlayerStream not working on Android 9. It not play online radio at all.

I check it both with mp3 and AAC streams. After launching (mp.Play) - after exact 30s, error event occurs:
Error: "MEDIA_ERROR_UNKNOWN", Extra data: -2147483648
 

Brian Dean

Well-Known Member
Licensed User
Longtime User
... MediaPlayerStream not working on Android 9.
This is not much information to go on. Do you mean that it is working on Android 8 and Android 10? Everything else that you have told us suggests a setup error in the coding.

Post your code.
 
Upvote 0

Wolodymyr

Member
It is standard code. It working normal on Huawei Y6-2 (Android 6.0) and Bluestacks emulator. But does not work on Xiaomi A1 (Android 9.0).
TargetSDK is set to 29

Playing Online Radio code:
Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.
    Dim MP As MediaPlayerStream
End Sub

Sub Activity_Create(FirstTime As Boolean)
    If FirstTime then MP.Initialize("mp")
    Activity.LoadLayout("Layout")
End Sub

Sub Button1_Click
    MP.Load("http://radio.ukr.radio:8000/ur1-aacplus-l") 'AAC+ stream
    'MP.Load("http://radio.ukr.radio:8000/ur1-mp3-m") 'MP3 stream
    Log("Load stream URL into RADIO")
End Sub

Sub mp_StreamReady
    Log("RADIO ready to playing")
    MP.SetVolume(1,1)
    MP.Play
End Sub

Sub mp_StreamError (ErrorCode As String, ExtraData As Int)
    Log("Error: " & ErrorCode & ", " & ExtraData)
    ToastMessageShow("Error: " & ErrorCode & ", " & ExtraData, True)
End Sub

Sub mp_StreamBuffer(Percentage As Int)
    Log(Percentage)
End Sub
 
Upvote 0

Wolodymyr

Member
28 - Non-ssl (non-https) communication is not permitted by default. It can be enabled in B4A v9+ by adding this line to the manifest editor:
CreateResourceFromFile(Macro, Core.NetworkClearText)

This modification to manifest really help. Thanks Erel
 
Upvote 0
Top