Problem initializing MediaPlayer in Service...

PaulR

Active Member
Licensed User
Longtime User
I am trying to move the MediaPlayer in my app into a service, but it is giving a compiliation error....
B4X:
Compiling code.                         Error
Error compiling program.
Error description: Object reference not set to an instance of an object.
Occurred on line: 22
mediaPlayer1.Initialize("MP")
Word: (

I am declaring it here....
B4X:
'Service module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim mediaPlayer1 As MediaPlayer
.... and trying to initialize it here....
B4X:
Sub Service_Create
   mediaPlayer1.Initialize("MP")
End Sub

What am I doing wrong?
 
Top