Skip to content

Commit

Permalink
Исправил перезапуск плеера
Browse files Browse the repository at this point in the history
  • Loading branch information
yaa43rry committed Feb 16, 2010
1 parent 9819cea commit 5faaa25
Showing 1 changed file with 21 additions and 12 deletions.
33 changes: 21 additions & 12 deletions src/blueforms/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Client extends MIDlet implements CommandListener {
ToneControl.C4 + 11, 2, ToneControl.C4 + 16, 2,
ToneControl.C4 + 11, 2, ToneControl.BLOCK_END, 0,
ToneControl.PLAY_BLOCK, 0 };
Player player;
Player player = null;
boolean isFail;
// long onlineTime;

Expand Down Expand Up @@ -166,6 +166,19 @@ protected void startApp() throws MIDletStateChangeException {
hardAlert.setCommandListener(this);

isFail = false;

try {
player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
player.realize();
ToneControl tcl = (ToneControl) player.getControl("ToneControl");
tcl.setSequence(NOTS);
player.setLoopCount(-1);
} catch (IOException e1) {
e1.printStackTrace();
} catch (MediaException e1) {
e1.printStackTrace();
}

// ------------------------------------------------------------------

try {
Expand Down Expand Up @@ -251,8 +264,10 @@ public void monitor() {
if (!stop){
monitorTask = new MonitorTask(this);
monitorTimer.schedule(monitorTask, 100);
} else
} else {
display.setCurrent(hardAbsence);
forceTask.cancel();
}
}

public void failOn() {
Expand All @@ -262,15 +277,8 @@ public void failOn() {
isFail = true;
display.setCurrent(hardAlert);
try {
player = Manager.createPlayer(Manager.TONE_DEVICE_LOCATOR);
player.realize();
ToneControl tcl = (ToneControl) player.getControl("ToneControl");
tcl.setSequence(NOTS);
player.setLoopCount(-1);
player.start();
debug(">");
} catch (IOException e) {
ShowError("IO: " + e.toString());
} catch (MediaException e) {
ShowError("Media: " + e.toString());
}
Expand All @@ -285,10 +293,10 @@ public void failOff() {
display.setCurrent(hardStatic);
try {
player.stop();
debug("|");
} catch (MediaException e) {
ShowError("Media2: " + e.toString());
e.printStackTrace();
}
debug("|");
}
}

Expand Down Expand Up @@ -392,7 +400,6 @@ else if (display.getCurrent() == hardStatic) {
// Ðàçðûâ ñîåäèíåíèÿ
if (c == breakCommand) {
stop = true;
forceTimer.cancel();
}
}

Expand Down Expand Up @@ -431,6 +438,8 @@ else if (display.getCurrent() == passChange) {
else if (display.getCurrent() == hardAlert) {
if (c == OKCommand) {
if (enterAlert.getString().equals(password)) {
stop = true;
forceTask.cancel();
failOff();
enterAlert.setString("");
passwordErrorAlert.setText("");
Expand Down

0 comments on commit 5faaa25

Please sign in to comment.