Android Question Media Player not installed, only Music - how to get ID?

Mark Read

Well-Known Member
Licensed User
Longtime User
I am writing a visualisation program for music files. Running my program on a real device is no problem as media player is installed. However, running on the emulator, the program crashes when trying to get the ID of the session.

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 MediaPlayer
   Dim Viz As Vizualizer
End Sub
Sub Activity_Create(FirstTime As Boolean)
   'Initialize the Mediaplayer
   'Load a file
   MP.Load(File.DirAssets,"test.mp3") '(and add it to the files tab)
    'Get the MediaPlayer Object from it's wrapper
    Dim R As Reflector
    R.Target = MP
    Dim MPJO As JavaObject = R.GetField("mp")
    'Get the audio session Id
    Dim AudioSession As Int = MPJO.RunMethod("getAudioSessionId",Null)

The last line causes the crash with the error:

java.lang.RuntimeException: Method: getAudioSessionId not found in:

Getting the installed packages I can see that the player is actually called

I have to use the emulator for the moment as I have no real device available.
Has anyone got a workaround for this problem.

Many thanks.