# Video problems

**URL:** <https://forum.kirupa.com/t/video-problems/287403>\
**Category:** flash\
**Created:** [April 30, 2009, 2:53pm UTC](https://forum.kirupa.com/t/video-problems/287403 "2009-04-30T14:53:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neas](https://avatars.discourse-cdn.com/v4/letter/n/dec6dc/32.png) [@neas](https://forum.kirupa.com/u/neas)\
**Post date:** [April 30, 2009, 2:53pm UTC](https://forum.kirupa.com/t/video-problems/287403/1 "2009-04-30T14:53:28Z")

</div>

Hi,  
I have a small video player in a flash page, it works but when I go to another frame (or page) then the video is still playing in the background, how can I get it to stop playing when I leave that frame. Also, I need to be able to go back to that frame and play through the videos again. Thanks, here is my code

```auto

var videoConnection:NetConnection = new NetConnection();
videoConnection.connect(null);

var videoStream:NetStream = new NetStream(videoConnection);
videoStream.play("video/vid1.flv");

var video:Video = new Video();
video.attachNetStream(videoStream);

//ADD VIDEO TO STAGE/MOVIE CLIP
videoplayer_mc.addChild(video);
video.width = 640;
video.height = 360;
video.x = 20;
video.y = 20;

var metaListener:Object = new Object();
metaListener.onMetaData = onMetaData;
videoStream.client = metaListener;

function onMetaData(data:Object):void {
    vid1_btn.addEventListener(MouseEvent.CLICK, playMovie);
    vid2_btn.addEventListener(MouseEvent.CLICK, stopMovie);

}

function playMovie(event:MouseEvent):void {
    videoStream.play("video/vid1.flv");
}

function stopMovie(event:MouseEvent):void {
    videoStream.pause();
}

```
