I have successfully implemented the Media Player for my apps, but when I tried to use some of the callback methods I ran into a problem.
What I'm trying to do is use Media Player in a reusable (library) class. This MediaPlayer is created by passing the Activity Context to it's constructor. I then use getApplicationContext to avoid any potential memory leaks. This works well and I'm quite happy with it. My problem is trying to use callbacks. When I implement MediaPlayer.OnPreparedListener in my class (that doesn't extend an Activity) I repeatedly get this error: Illegal State Exception: PrepareAsync called in state 8 This error only occurs on the line: mp.prepare(); I believe this is due to the class itself not being an Activity. When I implemented the callbacks in a separate test project, the mp.prepare () works fine. I cannot use a passed context to my library class, as that would require the Activity to implement the listener and not my library class. How can I create a library class that creates/uses MediaPlayer and it's callbacks without making it extend Activity? Is this not possible? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---