VideoControl

The VideoControl is used to control an external MP4 video file:

  • play / pause
  • set playback speed
  • set the time position within the video

To use VideoControl, enter the video .mp4 filename in the videoFileName parameter. Then place a Video object on the screen and give it an instance name – enter the name of the Video object in the videoObjectName parameter . This widget also works with the ListItems widget so that it can play videos from list specified in the ListItems widget.

For pause or any of the restart behaviors, inputSource values below 500 will pause the video and sound, values 500 or greater will play the video. For speed, an inputSource value of 100 is normal forward speed, where a value of zero is stopped, and negative values play the video in reverse. For time, the input value positions to a video frame, assuming 30fps. The speed and time settings do not play sound.

Video files used with the TIME and SPEED behaviors must be encoded with the Adobe Media Encoder with keyframes every frame – see below for encoding instructions.

On-screen Features

  • top row right – Behavior of video – time, speed,pause,restart,restartPlayToEnd,restartPlayToEndInterrupt (see videoBehavior parameter below).
  • middle row
    • in – instance name of the inputSource and the values coming from it
    • playing state – stopped, playing, paused, etc.
    • input value – the value from the inputSource
  • bottom row –  Filename of the video being played

Parameters

  • hideVideo – if checked and used in combination with the pause or restart videoBehaviors, the video will only display while it is playing – useful when several videos are stacked on top of each other, but play under different conditions.
  • inputSource –  the instance name of the source the widget listens to, e.g AnalogIn or DigitalIn
  • invisible – If set to “true” or checked, the widget will disappear when the Flash movie is run
  • listItemName – If set to other than the default of “none”, VideoControl will request the next list item from the ListItems widget that’s named in this parameter, each time the video is restarted. Requires that videoBehavior is set to one of the restart settings.
  • loopVideo – determines if the video will loop or not
  • threshold – this will set the point at which the video will play/pause if the playPause video property is selected.
  • videoFileName the file name of the .mp4 video you want to display – should be in the same directory as the .swf, and must be encoded with a keyframe every frame to use the time and speed properties.
  • videoObjectName the instance name of the video object you placed on the Flash stage from the library
  • videoBehavior – the property of the video that will be affected.
    • time – positions the video to a time in the video corresponding to the inputSource value multiplied by 0.03333333 which is the length of a video frame at 30 FPS. In other words, if the video is 10 seconds long, an inputSource value of 300 would position the video to the end of the video. No sound will play with this behavior.
    • speed sets the playback speed of the video based on the inputSource value where 100 is normal speed, 0 is stopped, and -100 is backwards at normal speed. For example, if the sensor value is 50, the video will play at half speed in the forward direction. If the sensor value is 200, the video will play at double speed forward. If the sensor value is -100, the video will play at normal speed, but backwards because the value is negative (note that you can put negative values in the AnalogIn widget min and max fields). For speed, if the loop parameter is set to yes, when the video gets to the beginning or end, it will loop around. So if it is playing forward, it will go back to the beginning, and if it is playing backwards, it will go back to the end after the beginning of the video is played. No sound will play with this behavior.
    • pause – plays the video when inputSource values are greater than or equal to the threshold (by default 500). If the value is less than the threshold, the video will pause. When the value goes above the threshold again, the video will resume at the position it was paused. This behavior will play sound along with the video.
    • restart – plays the video when inputSource values are greater than or equal to the threshold (by default 500). If the value is less than the threshold, the video will pause. When the value goes above the threshold again, the video with either restart playing from the begining or resume at the position it was paused at depending on the value of the playPauseBehavior parameter (restart or pause). This is the only property that will play sound along with the video.
    • restartPlayToEnd – the same as restart, but the video will continue to play until it finishes, even if the inputSource value falls below the threshold, or then rises above the threshold. The video will play to its end no matter what.
    • restartPlayToEndInterrupt – the same as restart, but the video will continue to play until it finishes, even if the inputSource value falls below the threshold. But if the inputSource value rises above the threshold again, it will interrupt the current video, and start playing from the beginning – if the widget is using a listItems widget, the next video will be played.

Placement of video in Flash

To use an external video file in Flash, do the following:

  • in the Library panel (Window > Library), select New Video from the Library pop-up menu
  • in the resulting Video Properties dialog box, name the video symbol and select Video (ActionScript controlled)
  • click OK to create a video object
  • drag the video object from the Library panel to the Stage to create a video object instance.
  • with the video object selected on the Stage, type a name in the Instance Name text box in the Property inspector. this is the name you will use in the VideoName parameter for the videoName parameters settings.

Preparation of Video for SPEED and TIME settings

Encode your video using the Adobe software called Adobe Media Encoder. It accepts many video formats and converts them into the propietary format for Flash. Open the application and do the following:

  • click on ADD and add a video source to the queue, or drag the video source from your desktop onto the queue area
  • click on the Presets area for this video – this will bring up an Export Settings dialog
  • in the Export Settings dialog, select H.264 in the Format pulldown menu
  • set the file name for the encoded file where it says Output Name – this is the name you will use in the videoFileName parameter in parameters settings of VideoControl
  • if you are using the time or speed widget settings, uncheck Export Audio, and leave Export Video checked
  • select the Video tab
  • resize the video dimensions if necessary – make it as small as possible for best performance
  • if you have performance issues, choose a Frame Rate of 15 frames/sec instead of 30
  • under the Bitrate Settings set Bitrate Encoding to VBR 2 Pass
  • set the Bitrate (Mbps) to your choice depending on the size and quality you want. A good starting point is 1 Mbps megabits/sec (Mbps).
  • if you are using the time or speed widget settings, under Advanced Settings check Key Frame Distance, and set Key Frame Distance  to 1 frames. This will enable the time and speed widget settings to position the video to every frame, and enable reverse playback. This is not necessary of you are using the pause or restart settings.
  • select OK to accept your settings and then click on the green right arrow button to start the encoding of the video.
  • place the resulting video in the same directory where your Flash document resides

Code Interface

The VideoControl code interface enables the user to control the play, pause, and video file name of the widget. This allows for a simple way to play or pause a video, or to change the .mp4 file being played.

In all of the below examples, the code assumes that there is a VideoControl widget on the stage with the instance name “myVideoControl”.

playVideo(speedOrTime:Number)

Makes the VideoControl widget play the most recently set video file name. If the videoProperty is set to “speed” the speedOrTime value will set the speed value for playing the video – if no value is included, it will default to normal play speed of 100. If the videoProperty is set to “time” the speedOrTime value will set the time position of the video – if no value is sent, the time position will not be set.

myVideoControl.playVideo(100);

pauseVideo()

Makes the current video pause.

myVideoControl.pauseVideo();

setVideoFilename(filename:String)

Sets the name of the video that will be displayed the next time playVideo() is called, or when the value from the input source is equal to or greater than the threshold.

myVideoControl.setVideofilename("dancer.mp4");

Last modified March 3rd, 2015