Android Question Ringtone Manager not working on Android Boxes

EduardoElias

Well-Known Member
Licensed User
Longtime User
Hi there

I am trying to make a ring tone work on those Android boxes for TV

Using this: https://www.b4x.com/android/forum/threads/default-message-sound.56476/#post-355337

However no sound is produced. Going to android config there is default tones defined and I can listen to them.

I have here on called MXQ with android 6.0.1 and tested with a MX9 with android 7.1.2 both cases no sound from Ringtone Manager

Any help appreciated. THanks
 

EduardoElias

Well-Known Member
Licensed User
Longtime User
Note that you can use RingtoneManager.Play instead of that code.

Are you able to play sounds with SoundPool or MediaPlayer?

Tested right now with SoundPool and no sound.

Got this code from the forum and added my wav file. On windows this wav file works.

B4X:
Sub PlayRecording
    Dim ret As Int 'Used in call to Pool.Play. ret = 0 if error occurs
    Dim PoolID As Int 'Identifies the Pool number when a sound file is loaded
    Dim SourceDir As String = File.DirInternal 'or the Directory where your file is located
    Dim SourceFileName As String = "restaurantbell.wav" 'The file you wish to use
    Dim VolumeLeft As Double = 1 ' = Value between 0 and 1 for Left Channel
    Dim VolumeRight As Double = 1 ' = Value between 0 and 1 for Right Channel
    Dim Pitch As Double = 1 '= Value between 0 and 2: <1 is low pitch, 1 is normal, 2 is highest pitch
    Dim Priority As Int = 1 'SoundPool Documentation says this value is irrelevant, is for future use
    Dim Loopx As Int = 0 'Number of times to repeat the sound, -1 to repeat indefinitely

    'Load the sound
    PoolID = Pool.Load(SourceDir,SourceFileName) 'Loads the file and gets it's number in the pool.

    Sleep(100) 'Some delay required between pool loading and playback - I'm unsure why or how much?

    'Play the sound
    ret = Pool.Play(PoolID,VolumeLeft,VolumeRight,Priority,Loopx,Pitch)
End Sub
 
Upvote 0

EduardoElias

Well-Known Member
Licensed User
Longtime User
What about MediaPlayer?
B4X:
Sub PlayMedia
    Dim MediaPlayer As MediaPlayer
    MediaPlayer.Initialize
    MediaPlayer.Load(File.DirAssets, "restaurantbell.wav")
    MediaPlayer.Play
End Sub

This worked perfectly.

Why that? How can I know which one can I use? Is this related to this kind of device?
 
Upvote 0
Top