English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

var a=0;

function playSong () {
mediaPlayer.Play();
a = 1;
}

function pauseSong(){
mediaPlayer.Pause();
a = 2;
}

function playPauseButton() {
if (a == 1) {
pauseSong();
}
else if(a==2) {
playMedia();
}
}

playSong() will play the song when i press play button on remote control. pauseSong() will pause the song when i press pause button on remote control. Since i want to create a new button & want this new button to have click 1st time to pause the song, then click 2nd time to play the song again, then click again to pause the song & so on...

So i write the playPauseButton() function. But i only can pause the song & cannot play the song with clicking the same button. Why?

2007-07-01 19:46:48 · 4 answers · asked by scottcky1985 3 in Computers & Internet Programming & Design

4 answers

If I understand the question you want a toggle. When you press the button it plays the song, press it again it pauses, every time you press the button it reverses the previous action.
Try this:
var a=0;
function playPauseButton() {
if (a == 1) {
pauseSong();
}
else {
playSong();
}
a=1-a;
}

2007-07-09 05:27:22 · answer #1 · answered by Steve F 3 · 0 0

You are calling the function playMedia() and I think it is playSong() you want to call. Last function should be:

function playPauseButton() {
if (a == 1) {
pauseSong();
}
else if(a==2) {
playSong();
}
}

Your brackets are fine by the way.

2007-07-02 02:56:32 · answer #2 · answered by Anonymous · 0 0

The variable a has three values. Why is this when only two are required.
Change the pauseSong() value of a to be 0.
Now change your test
if (a==0) {
playMedia();
} else {
pauseSong() {
}

2007-07-02 03:02:09 · answer #3 · answered by AnalProgrammer 7 · 0 0

Hi,
Check the code






Click

2007-07-02 02:56:32 · answer #4 · answered by benaya p 1 · 0 0

fedest.com, questions and answers