1 Reply Latest reply on May 10, 2006 7:23 AM by Applied CD

    Full screen movie

    jpp01uk
      Hi Everyone, hoping someone can help me out. Im creating an E-Learning application based around video tutorials. The tutorials are in a small window based in the application. What I would like to do is allow the user to switch to full screen video if they wish, and then back again without the movie starting from the beginning.

      Im new to director so not 100% on how to do it.

      Thank you
        • 1. Re: Full screen movie
          Applied CD Level 1
          Here is something I wrote a few years ago. It will allow you to create a button to zoom a video sprite to full screen and use the ESC key to return to normal. Pressing the ESC key while in normal view will exit the projector. The video will scale to preserve the aspect ratio of the original sprite with black boarders filling the rest of the space (ie: the video will not distort) … I think Windows Media Player literally fills the screen with video which usually results in a distorted image. Known limitations: As written, these behaviors will always put the full screen video on the primary monitor when playing on a mutlimonitor system. This code has never been tested on a Mac but there’s nothing in it that shouldn’t work. My original scripts had some project specific code that I have tried to remove for this post, I apologize if I’ve left some garbage behind.

          To start off with:
          1. Draw a black rectangle the same size as your stage. Make sure this rectangle is above all other sprites. Set the blend of this sprite to 0.
          2. Place your video sprite on top of this rectangle (the next higher channel ). The video sprite can be any size and location required by your layout.

          Create the following movie script. Important – change the value of gVideoSprite to match the sprite number of your video:

          on startMovie
          global gFullScreenMode
          global gVideoSprite
          global gVideoDurationSlop

          gFullScreenMode = FALSE
          gVideoSprite = 30
          gVideoDurationSlop = 200
          end

          Create the following behavior, place the behavior in the frame script box of the last frame containing your video sprite. This behavior keeps the playback head holding in the current frame. It also looks to see if the video has ended while in full screen mode, if the video has ended it automatically restores the screen to normal.

          on exitFrame me
          global gFullScreenMode
          global gVideoSprite
          global gVideoDurationSlop

          if gFullScreenMode then
          if sprite(gVideoSprite).movieTime >= (sprite(gVideoSprite).member.duration-gVideoDurationSlop) then restoreScreen
          end if
          go the frame
          end

          Create the following behavior and place the behavior on a button to be used to activate the zoom.

          on mouseUp me
          global gFullScreenMode

          if not(gFullScreenMode) then zoomFullScreen
          end

          Create the following movie script. This is where the real work is done. Note that the line sprite(gVideoSprite).loc = point(-1000,-1000) is intended to move the video sprite off the stage while it is being resized, if for some reason you have a HUGE video sprite you might need to move it further.

          on zoomFullScreen
          global gFullScreenMode
          global gOriginalStageRect
          global gOriginalVideoRect
          global gVideoSprite
          global gVideoDurationSlop


          gOriginalStageRect = (the stage).rect
          gOriginalVideoRect = sprite(gVideoSprite).rect
          sprite(gVideoSprite).loc = point(-1000,-1000)
          updateStage
          (the stage).rect = _system.deskTopRectList[1]
          sprite(gVideoSprite-1).rect = (the stage).rect
          sprite(gVideoSprite-1).blend = 100
          updateStage
          videoSpriteH = gOriginalVideoRect[4] - gOriginalVideoRect[2]
          videoSpriteW = gOriginalVideoRect[3] - gOriginalVideoRect[1]
          newStageH = (the stage).rect[4] - (the stage).rect[2]
          newStageW = (the stage).rect[3] - (the stage).rect[1]
          zoomFactor = float(newStageH) / float(videoSpriteH)
          testW = videoSpriteW * zoomFactor
          if testW > newStageW then zoomFactor = float(newStageW) / float(videoSpriteW)
          newVideoH = videoSpriteH * zoomFactor
          newVideoW = videoSpriteW * zoomFactor
          gapH = (newStageH - newVideoH)/2
          gapW = (newStageW - newVideoW)/2
          rectLeft = gapW
          rectRight = gapW + newVideoW
          rectTop = gapH
          rectBottom = gapH + newVideoH
          videoRect = rect(rectLeft,rectTop,rectRight,rectBottom)
          sprite(gVideoSprite).rect = videoRect
          updateStage
          gFullScreenMode = TRUE
          if sprite(gVideoSprite).movieTime >= (sprite(gVideoSprite).member.duration-gVideoDurationSlop) then replayVideo
          end

          Create the following movie script, this script watches for the ESC key and restores the screen when pressed. See the very important note at this end of this post about the EXIT LOCK option.

          on closeRequest
          global gFullScreenMode

          if gFullScreenMode then
          restoreScreen
          else
          halt
          end if
          end

          Create the following movie script, this does the real work of restoring the screen to normal.

          on restoreScreen
          global gFullScreenMode
          global gOriginalStageRect
          global gOriginalVideoRect
          global gVideoSprite

          (the stage).rect = gOriginalStageRect
          sprite(gVideoSprite-1).blend = 0
          sprite(gVideoSprite-1).rect = gOriginalStageRect
          sprite(gVideoSprite).rect = gOriginalVideoRect
          updateStage
          gFullScreenMode = FALSE
          end

          Create the following movie script. The only purpose for this script is to re-queue the video if someone hits the full screen while when the video is idle.

          on replayVideo
          global gVideoSprite

          sprite(gVideoSprite).movieTime = 0
          sprite(gVideoSprite).movieRate = 1
          end

          Finally, and this is very important, under your publish settings, hit the projector tab and check the EXIT LOCK option. This will prevent the ESC key from exiting the projector while in full screen mode.