| Package | com.soma.view.video.controls |
| Class | public class SomaVideoControls |
| Inheritance | SomaVideoControls flash.display.Sprite |
Author: Romuald Quantin - www.soundstep.com
Information:
Blog page - SomaUI
How does it work - Soma Protest
Project Host - Google Code
Documentation - Soma ASDOC
Class version: 2.0
Actionscript version: 3.0
Copyright:
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied.
See the License for the specific language governing rights and
limitations under the License.
The Original Code is Soma.
The Initial Developer of the Original Code is Romuald Quantin.
Initial Developer are Copyright (C) 2008-2009 Soundstep. All Rights Reserved.
Usage:
The SomaVideoControls handles default controls or an undefined number of controls added to this class. SomaVideoControls is extending a Sprite and be accessed through the "controls" property of a SomaVideoPlayer instance.
Everytime a control is added to the instance, it will layout them from left to right (and strech the time bar when the property fitToVideo is set to true). You have some properties to reach common layouts:
var controls:SomaVideoControls = new SomaVideoControls();
controls.addControl(new SomaVideoPlaySkin());
controls.addControl(new SomaVideoTimeBarSkin());
controls.addControl(new SomaVideoMuteSkin());
controls.addControl(new SomaVideoFullscreenSkin());
var player:SomaVideoPlayer = new SomaVideoPlayer("video/video.flv", controls);
addChild(player);
addSkinController(PlayController, ISomaVideoPlaySkin);
addSkinController(MuteController, ISomaVideoMuteSkin);
addSkinController(FullscreenController, ISomaVideoFullscreenSkin);
addSkinController(TimeBarController, ISomaVideoTimeBarSkin);
package {
import com.soma.view.video.controls.ISomaVideoSkin;
public interface IBufferSkin extends ISomaVideoSkin {
function bufferCallBack(bufferLength:Number, bufferTime:Number):void;
}
}
package com.somaprotest {
import com.soma.view.video.SomaVideoPlayer;
import flash.display.Sprite;
public class BufferSkin extends Sprite implements IBufferSkin {
private var _player:SomaVideoPlayer;
public function BufferSkin() {
createSkinElements();
}
private function createSkinElements():void {
// create graphic skin element here
}
public function bufferCallBack(bufferLength:Number, bufferTime:Number):void {
// handle graphic skin elements with the data received
trace("BUFFERING > bufferLength: ", bufferLength, ", bufferTime: ", bufferTime);
}
public function registerPlayer(player:SomaVideoPlayer):void {
_player = player;
}
public function dispose():void {
// This method is internally called when you dispose a SomaVideoPlayer
// to remove children, the event listeners or whatever that needs to be
// destroyed to free the memory (make the instance elligible to the
// Garbage Collection).
}
}
}
package com.somaprotest {
import com.soma.view.video.events.SomaVideoEvent;
import com.soma.view.video.SomaVideoPlayer;
import com.soma.view.video.controls.ISomaVideoDisposable;
public class BufferController implements ISomaVideoDisposable {
private var _videoPlayer:SomaVideoPlayer;
private var _skin:IBufferSkin;
public function BufferController(videoPlayer:SomaVideoPlayer, skin:IBufferSkin) {
_videoPlayer = videoPlayer;
_skin = skin;
_videoPlayer.addEventListener(SomaVideoEvent.BUFFERING_START, eventsHandler);
_videoPlayer.addEventListener(SomaVideoEvent.BUFFERING_PROGRESS, eventsHandler);
_videoPlayer.addEventListener(SomaVideoEvent.BUFFERING_COMPLETE, eventsHandler);
}
public function eventsHandler(e:SomaVideoEvent):void {
_skin.bufferCallBack(_videoPlayer.bufferLength, _videoPlayer.bufferTime);
}
public function dispose():void {
_videoPlayer.removeEventListener(SomaVideoEvent.BUFFERING_START, eventsHandler);
_videoPlayer.removeEventListener(SomaVideoEvent.BUFFERING_PROGRESS, eventsHandler);
_videoPlayer.removeEventListener(SomaVideoEvent.BUFFERING_COMPLETE, eventsHandler);
}
}
}
var controls:SomaVideoControls = new SomaVideoControls();
controls.addSkinController(BufferController, IBufferSkin);
controls.addControl(new BufferSkin());
var player:SomaVideoPlayer = new SomaVideoPlayer("video/video.flv", controls);
addChild(player);
See also
| Property | Defined by | ||
|---|---|---|---|
| alignBottom : Boolean Specifies whether the controls are aligned to the bottom or to the top (default true).
| SomaVideoControls | ||
| backgroundAlpha : Number Specifies the background transparency of the controls (default alpha 0.5).
| SomaVideoControls | ||
| backgroundColor : uint Specifies the background color of the controls (default black).
| SomaVideoControls | ||
| fitToVideo : Boolean Specifies whether the width of the controls will fit to the video width (set this property
to false to have a complete control of the size and position), default true.
| SomaVideoControls | ||
| margin : Number Specifies the margin around the skin (default is 5).
| SomaVideoControls | ||
| sitOnVideo : Boolean Specifies whether the controls are "on" or "outside" the video screen (default true).
| SomaVideoControls | ||
| Method | Defined by | ||
|---|---|---|---|
|
create a SomaVideoControls instance.
| SomaVideoControls | ||
|
addControl(control:ISomaVideoSkin):void
Add a control to the list, example: SomaVideoPlaySkin.
| SomaVideoControls | ||
|
addSkinController(controllerClass:Class, skinInterface:Class):void
Add a controller and its skin.
| SomaVideoControls | ||
|
dispose():void
This method is internally called when you dispose a SomaVideoPlayer to remove children, the event listeners or whatever that needs to be destroyed to free the memory (make the instance elligible to the Garbage Collection).
| SomaVideoControls | ||
|
draw():void
Draw (layout) the controls.
| SomaVideoControls | ||
|
getControl(classType:Class):ISomaVideoSkin
Get a control using the class.
| SomaVideoControls | ||
| alignBottom | property |
alignBottom:Boolean [read-write]Specifies whether the controls are aligned to the bottom or to the top (default true).
Implementation public function get alignBottom():Boolean
public function set alignBottom(value:Boolean):void
| backgroundAlpha | property |
backgroundAlpha:Number [read-write]Specifies the background transparency of the controls (default alpha 0.5).
Implementation public function get backgroundAlpha():Number
public function set backgroundAlpha(value:Number):void
| backgroundColor | property |
backgroundColor:uint [read-write]Specifies the background color of the controls (default black).
Implementation public function get backgroundColor():uint
public function set backgroundColor(value:uint):void
| fitToVideo | property |
fitToVideo:Boolean [read-write]Specifies whether the width of the controls will fit to the video width (set this property to false to have a complete control of the size and position), default true.
Implementation public function get fitToVideo():Boolean
public function set fitToVideo(value:Boolean):void
| margin | property |
margin:Number [read-write]Specifies the margin around the skin (default is 5).
Implementation public function get margin():Number
public function set margin(value:Number):void
| sitOnVideo | property |
sitOnVideo:Boolean [read-write]Specifies whether the controls are "on" or "outside" the video screen (default true).
Implementation public function get sitOnVideo():Boolean
public function set sitOnVideo(value:Boolean):void
| SomaVideoControls | () | constructor |
public function SomaVideoControls()create a SomaVideoControls instance.
| addControl | () | method |
public function addControl(control:ISomaVideoSkin):voidAdd a control to the list, example: SomaVideoPlaySkin.
Parameterscontrol:ISomaVideoSkin |
| addSkinController | () | method |
public function addSkinController(controllerClass:Class, skinInterface:Class):voidAdd a controller and its skin.
ParameterscontrollerClass:Class — A class.
|
|
skinInterface:Class — A class.
|
| dispose | () | method |
public function dispose():voidThis method is internally called when you dispose a SomaVideoPlayer to remove children, the event listeners or whatever that needs to be destroyed to free the memory (make the instance elligible to the Garbage Collection).
| draw | () | method |
public function draw():voidDraw (layout) the controls.
| getControl | () | method |
public function getControl(classType:Class):ISomaVideoSkinGet a control using the class.
ParametersclassType:Class — A Class.
|
ISomaVideoSkin —
A Class typed ISomaVideoSkin.
|