Yo lo tengo asi :
Tengo un servicio que se llama srvExoPlayer
'---------------- Modulo Main -------------------'
Al abrir la emisora :
Sub AbrirEmisora
StartService(srvExoPlayer)'iniciar servicio
CallSubDelayed(srvExoPlayer,"Iniciar_musica")'abrir exoplayer
End Sub
'---------------- Modulo srvExoPlayer -------------------'
Sub Process_Globals
Public Exo1 As SimpleExoPlayer
Private ListaSources As List
Private NotiNB6 As NB6 ''Notificacion NB6 'https://www.b4x.com/android/forum/threads/91819/#content
End Sub
Sub Service_Create
Service.AutomaticForegroundMode = Service.AUTOMATIC_FOREGROUND_NEVER
Exo1.Initialize("mp1")'tu exoplayer
ListaSources.Initialize'lista con links de emisora
End Sub
Sub Service_Start (StartingIntent As Intent)
StartServiceAt(Me, DateTime.Now + 30 * DateTime.TicksPerMinute, True)'reiniciar cada x
End Sub
Public Sub Iniciar_musica
ListaSources.Clear'lista con links de emisora
Dim url As String = '...... emisora que quieres
If url.Contains("m3u8") Then
ListaSources.Add(Exo1.CreateHLSSource(url))
Else
ListaSources.Add(Exo1.CreateUriSource(url))
End If
Exo1.Prepare(Exo1.CreateListSource(ListaSources))
Exo1.Play
End Sub
Sub mp1_Ready
Exo1.Play'iniciar exoplayer
PonerNotificacion'poner notificacion
End Sub
Sub CreateNotificationNB6 As Notification
Dim texto As String = '........
Dim bm As Bitmap = '...........
NotiNB6.Initialize("default", Application.LabelName, "DEFAULT").SmallIcon(bm)
NotiNB6.SetDefaults(False, False, False)
NotiNB6.Color(Colors.Blue)
NotiNB6.Colorized(True)
NotiNB6.LargeIcon(bm)
If Version >=25 Then NotiNB6.MediaStyle
Return NotiNB6.Build("Musica" , texto, "tag", Main)
End Sub