Search code examples
androidmedia-player

Android MediaPlayer on UI Thread


When using android's mediaplayer to stream audio off the web, is it okay to call all the functions (stop(), reset(), setDataSource(), etc.) on the UI thread, or should I create a separate thread for that. In other words, will those functions ever take a few seconds to respond and thereby cause perceptible lag?

If I do have to call them from separate threads, what's the best way to handle that?


Solution

  • I call MediaPlayer methods off the default app thread without any issues. Do be sure to make proper use of its state machine, of course :)