Android Question RingtoneManager won't stop

Status
Not open for further replies.

NeoTechni

Well-Known Member
Licensed User
Longtime User
I've searched already and the 3 other topics about stopping the RingtoneManager don't actually use it for playing, they use a separate JavaObject to play and use the RingtoneManager just to look up the URI.

I am using it to play, and now it won't stop till I full-stop the app
I tried RM.Play("") and that just plays the notification noise.

How do you stop the RingetoneManager? I assume it has the ability cause otherwise it's playback capabilities are useless

I still need an answer to this question despite the previous thread being closed.
 

JohnC

Expert
Licensed User
Longtime User
You should try to use soundpool instead because you'll have more control:

 
Last edited:
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
How do you stop the RingetoneManager though? I assume it has the ability cause otherwise it's playback capabilities are useless
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
If you're not getting answers, probably people here haven't used this way to play sounds.
Maybe you can upload a small project showing the issue in order other people can try and test.
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
B4X:
'theType: -1=Stop, 0=Notification, 1=Alarm, 2=Ringtone
Sub UseRingtone(theType As Int, Optional FullVolume As Boolean = True)
    Private p As Phone, V As Int , NotificationManager As JavaObject, RM As RingtoneManager
    Select Case theType
        Case -1'STOP
            
            Log("STOP PLAYING!")
            Return
        Case 0
            theType = RM.TYPE_NOTIFICATION
            V = p.VOLUME_NOTIFICATION
        Case 1
            theType = RM.TYPE_ALARM
            V = p.VOLUME_ALARM
        Case 2
            theType = RM.TYPE_RINGTONE
            v = p.VOLUME_RING
    End Select
    If FullVolume And p.SdkVersion >= 24 Then
        NotificationManager = NotificationManager.InitializeContext.RunMethod("getSystemService", Array("notification"))
        If NotificationManager.RunMethod("isNotificationPolicyAccessGranted", Null) = True Then
            p.SetVolume(V , p.GetMaxVolume(V), False)
        End If
    End If
    RM.Play(RM.GetDefault(theType))
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I assume it has the ability cause otherwise it's playback capabilities are useless
You are consistently making it difficult for me to help you, but I will try one last time:
 
Upvote 0

NeoTechni

Well-Known Member
Licensed User
Longtime User
I don't know what you mean by that. I wasn't trying to insult the code but make a logical statement like how a car without brakes is useless as a car. As I tried the thing and it kept playing till I crashed it so I assumed I was missing something simple

If you mean that I should have looked for that thread, it didn't show up when I searched. 3 Old topics asking the same question that didn't actually solve the problem showed up and I was trying to be polite by not asking in them even though I feel making another topic makes it harder for the next person to find the answer. I even checked stack overflow since I keep running into people there

thank you for the solution
 
Upvote 0
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…