W wdegler Active Member Licensed User Longtime User Jan 30, 2020 #1 I have a test program with a class module and an MP3 file in the files list. The following code works in the main module: I hear the sound. Dim MP as MediaPlayer MP.Initialize MP.Load(File.DirAssets,"Note.MP3") MP.Play This same code does NOT work in the class module even though debugging does step through it.: I do not hear the sound. Can someone tell me why? It would be convenient in my project if there is a way to play the sound in the class module.
I have a test program with a class module and an MP3 file in the files list. The following code works in the main module: I hear the sound. Dim MP as MediaPlayer MP.Initialize MP.Load(File.DirAssets,"Note.MP3") MP.Play This same code does NOT work in the class module even though debugging does step through it.: I do not hear the sound. Can someone tell me why? It would be convenient in my project if there is a way to play the sound in the class module.
Jeffrey Cameron Well-Known Member Licensed User Longtime User Jan 30, 2020 #2 It should work in a service class, I've used a service class to control both mediaplayer and soundpool object without any issue. Just be sure in the Service_Destory to stop any mediaplayer/soundpool that might be on-going. Upvote 0
It should work in a service class, I've used a service class to control both mediaplayer and soundpool object without any issue. Just be sure in the Service_Destory to stop any mediaplayer/soundpool that might be on-going.
Erel B4X founder Staff member Licensed User Longtime User Jan 31, 2020 #3 Classes can do whatever activities and services can do. They share the context with their parent module (module where it was initialized). Please upload a small project which demonstrates the problem. Upvote 0
Classes can do whatever activities and services can do. They share the context with their parent module (module where it was initialized). Please upload a small project which demonstrates the problem.
W wdegler Active Member Licensed User Longtime User Feb 2, 2020 #4 Erel said: Classes can do whatever activities and services can do. They share the context with their parent module (module where it was initialized). Please upload a small project which demonstrates the problem. Click to expand... Thank you, Erel, for your response. It is good to know that sounds CAN be played in a class. I prepared a small project to illustrate the problem but it DOES work there so there is no reason for me to send it. My rather large project does not work with a class so I am now using an Activity module where it does work. Eventually, I expect to figure out why the class module did not work in my project. Thanks again. Upvote 0
Erel said: Classes can do whatever activities and services can do. They share the context with their parent module (module where it was initialized). Please upload a small project which demonstrates the problem. Click to expand... Thank you, Erel, for your response. It is good to know that sounds CAN be played in a class. I prepared a small project to illustrate the problem but it DOES work there so there is no reason for me to send it. My rather large project does not work with a class so I am now using an Activity module where it does work. Eventually, I expect to figure out why the class module did not work in my project. Thanks again.