views:

268

answers:

3

Hi
I have a simple page and a link on it which opens a simple popup ajax popup with embedded media player on it, like so

<object classid="..." id="mediaplayer1">
</object>

The problem is that after closing and disappearing popup it seems that Meda Player continues working, cause I am hearing movie sound. How can I stop this?

+1  A: 

Here is code to add it media player to your page: Webreference

Here is code to pause/play it: WebDeveloper

function handlePlayOrPauseClick(){
     var state;
      playerStatus = document.mediaPlayer.playState;
      if (playerStatus == 6) {
        document.mediaPlayer.play();
        document.playerCtrl.playOrPause.value = " Pause ";
      } 
      else if (playerStatus == 1) {
        document.mediaPlayer.play();
        document.playerCtrl.playOrPause.value = " Pause ";
      } 
      else if (playerStatus == 2) {
        document.mediaPlayer.pause();
        document.playerCtrl.playOrPause.value = " Play  ";
      }
}

You can use code for play/pause on window unload event to stop player.

TheVillageIdiot
Thanks a lot @TheVillageIdiot, I will try it now, but why is it continue to play? Is it normal behavior?
ArsenMkrt
to tell the truth can't say :(
TheVillageIdiot
+1  A: 

On the click of the close button of the popup with the media player in it, try removing the element. I'll use some jQuery for terseness:

$('#close_popup').click(function(e){ $('#mediaplayer1').remove(); });
Alex Sexton
A: 

I solve this by finding popup frame and setting contentWindow.location = ''

ArsenMkrt