/**
* Executes the demo
*/
public void run() {
final UiApplication app = getApplication();
if (app == null) {
return;
}
// Register the MediaActionHandler and MediaKeyListener
app.addMediaActionHandler(this);
app.addKeyListener(new MyMediaKeyListener());
// Push the main screen onto the display stack
final MediaPlayerDemoScreen screen = _screen;
if (screen != null) {
app.invokeLater(new Runnable() {
public void run() {
app.pushScreen(screen);
}
});
}
// Load the playlist, copying the files into the filesystem if they do
// not exist
final StatusScreen statusScreen =
new StatusScreen("Initializing media");
app.invokeLater(new Runnable() {
public void run() {
app.pushScreen(statusScreen);
}
});
PlaylistEntry[] playlist;
try {
playlist = PlayList.getPlaylistEntries();
} catch (final IOException e) {
MediaPlayerDemo.errorDialog("ERROR: " + e.getMessage());
playlist = null;
} finally {
app.invokeLater(new Runnable() {
public void run() {
app.popScreen(statusScreen);
}
});
}
// Update the screen to show the playlist
this._playlist = playlist;
if (playlist != null && screen != null) {
app.invokeAndWait(new Runnable() {
public void run() {
screen.setPlaylist(_playlist);
}
});
}