Packagecom.soma.view.video.skin
Classpublic class SomaVideoTimeBarSkin
InheritanceSomaVideoTimeBarSkin Inheritance flash.display.Sprite
ImplementsISomaVideoTimeBarSkin

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

http://www.mozilla.org/MPL/

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:
Default control skin for a SomaVideoPlayer time/preloading/buffering bar, automatically instantiated by the SomaVideoControls class if you dont specify one in the SomaVideoPlayer instance.

How to add controls to the player

The following code is reproducing how the default controls are added in the SomaVideoControls class (by default).

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);
     
Now you know to add controls to the player, you can build your own time/preloading/buffering bar skin. The base will be a DisplayObject class, such as Sprite, implementing SomaVideoTimeBarSkin.

Custom time/preloading/buffering bar class
package {
    import com.soma.view.video.SomaVideoPlayer;
 import com.soma.view.video.skin.ISomaVideoTimeBarSkin;

 import flash.display.Sprite;
    
    public class CustomTimeBarSkin extends Sprite implements ISomaVideoTimeBarSkin {
        
        private var _player:SomaVideoPlayer;
        
        public function CustomTimeBarSkin() {
            createSkinElements();
        }
        
        private function createSkinElements():void {
            // create elements here and use:
            // _player.seek(10);
        }
        
        public function registerPlayer(player:SomaVideoPlayer):void {
            _player = player;
        }
        
        public function dispose():void {
            // remove skin elements and events listeners for cleaning when the SomaVideoPlayer instance is disposed.
        }
        
        public function timeCallBack(time:Number, duration:Number):void {
            // here the controller will indicate when the time and duration of the video.
            trace("TIME > time: ", time, ", duration: ", duration);
        }
        
        public function preloadingCallBack(bytesLoaded:Number, bytesTotal:Number):void {
            // here the controller will indicate when the bytes loaded and the bytes total of the video .
            trace("PRELOADING > bytesLoaded: ", bytesLoaded, ", bytesTotal: ", bytesTotal);
        }
        
        public function bufferCallBack(length:Number, time:Number):void {
            // here the controller will indicate the current length of the buffer and the time it has to reach.
            trace("BUFFERING > length: ", length, ", time: ", time);
        }
        
    }
}
   
Add the CustomTimeBarSkin to the SomaVideoControls instead of the default one:
var controls:SomaVideoControls = new SomaVideoControls();
controls.addControl(new CustomTimeBarSkin());
var player:SomaVideoPlayer = new SomaVideoPlayer("video/video.flv", controls);
addChild(player);
     
Get a skin

var player:SomaVideoPlayer = new SomaVideoPlayer("video/video.flv");
addChild(player);
var skin:SomaVideoTimeBarSkin = player.controls.getControl(SomaVideoTimeBarSkin) as SomaVideoTimeBarSkin;
skin.backgroundColor = 0xFF0000;
skin.backgroundAlpha = .5;
skin.barHeight = 3;
     
See the SomaVideoControls documentation to add or create your own controls.

See also

Soma
SomaVideo
SomaVideoPlayer
SomaVideoEvent
SomaVideoControls
SomaVideoPlaySkin
SomaVideoMuteSkin
SomaVideoFullscreenSkin


Public Properties
 PropertyDefined by
  backgroundAlpha : Number
Specifies the background transparency of the skin (default alpha 0).
SomaVideoTimeBarSkin
  backgroundColor : uint
Specifies the background color of the skin (default is black).
SomaVideoTimeBarSkin
  barHeight : Number
Specifies the height of the bars.
SomaVideoTimeBarSkin
  durationBar : Sprite
[read-only] Get the duration bar.
SomaVideoTimeBarSkin
  durationBarAlpha : Number
Specifies the transparency of the duration bar (default is alpha 0.2).
SomaVideoTimeBarSkin
  durationBarColor : uint
Specifies the color of the duration bar (default is white).
SomaVideoTimeBarSkin
  preloadingBar : Sprite
[read-only] Get the preloading bar.
SomaVideoTimeBarSkin
  preloadingBarAlpha : Number
Specifies the transparency of the time bar (default is alpha 0.4).
SomaVideoTimeBarSkin
  preloadingBarColor : uint
Specifies the color of the preloading bar (default is white).
SomaVideoTimeBarSkin
  timeBar : Sprite
[read-only] Get the time bar.
SomaVideoTimeBarSkin
  timeBarAlpha : Number
Specifies the transparency of the time bar (default is alpha 1).
SomaVideoTimeBarSkin
  timeBarColor : uint
Specifies the color of the time bar (default is white).
SomaVideoTimeBarSkin
Public Methods
 MethodDefined by
  
Creates a SomaVideoPlaySkin instance.
SomaVideoTimeBarSkin
  
bufferCallBack(length:Number, time:Number):void
Methods called whenever the video is buffering.
SomaVideoTimeBarSkin
  
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).
SomaVideoTimeBarSkin
  
preloadingCallBack(bytesLoaded:Number, bytesTotal:Number):void
Methods called whenever the video is preloading.
SomaVideoTimeBarSkin
  
Register the SomaVideoPlayer instance that will be used with the skin class
SomaVideoTimeBarSkin
  
timeCallBack(time:Number, duration:Number):void
Methods called whenever the video playhead is updated to display the current time and duration in seconds of the video.
SomaVideoTimeBarSkin
Property detail
backgroundAlphaproperty
backgroundAlpha:Number  [read-write]

Specifies the background transparency of the skin (default alpha 0).

Implementation
    public function get backgroundAlpha():Number
    public function set backgroundAlpha(value:Number):void
backgroundColorproperty 
backgroundColor:uint  [read-write]

Specifies the background color of the skin (default is black).

Implementation
    public function get backgroundColor():uint
    public function set backgroundColor(value:uint):void
barHeightproperty 
barHeight:Number  [read-write]

Specifies the height of the bars.

Implementation
    public function get barHeight():Number
    public function set barHeight(value:Number):void
durationBarproperty 
durationBar:Sprite  [read-only]

Get the duration bar.

Implementation
    public function get durationBar():Sprite
durationBarAlphaproperty 
durationBarAlpha:Number  [read-write]

Specifies the transparency of the duration bar (default is alpha 0.2).

Implementation
    public function get durationBarAlpha():Number
    public function set durationBarAlpha(value:Number):void
durationBarColorproperty 
durationBarColor:uint  [read-write]

Specifies the color of the duration bar (default is white).

Implementation
    public function get durationBarColor():uint
    public function set durationBarColor(value:uint):void
preloadingBarproperty 
preloadingBar:Sprite  [read-only]

Get the preloading bar.

Implementation
    public function get preloadingBar():Sprite
preloadingBarAlphaproperty 
preloadingBarAlpha:Number  [read-write]

Specifies the transparency of the time bar (default is alpha 0.4).

Implementation
    public function get preloadingBarAlpha():Number
    public function set preloadingBarAlpha(value:Number):void
preloadingBarColorproperty 
preloadingBarColor:uint  [read-write]

Specifies the color of the preloading bar (default is white).

Implementation
    public function get preloadingBarColor():uint
    public function set preloadingBarColor(value:uint):void
timeBarproperty 
timeBar:Sprite  [read-only]

Get the time bar.

Implementation
    public function get timeBar():Sprite
timeBarAlphaproperty 
timeBarAlpha:Number  [read-write]

Specifies the transparency of the time bar (default is alpha 1).

Implementation
    public function get timeBarAlpha():Number
    public function set timeBarAlpha(value:Number):void
timeBarColorproperty 
timeBarColor:uint  [read-write]

Specifies the color of the time bar (default is white).

Implementation
    public function get timeBarColor():uint
    public function set timeBarColor(value:uint):void
Constructor detail
SomaVideoTimeBarSkin()constructor
public function SomaVideoTimeBarSkin()

Creates a SomaVideoPlaySkin instance.

Method detail
bufferCallBack()method
public function bufferCallBack(length:Number, time:Number):void

Methods called whenever the video is buffering.

Parameters
length:Number — A Number indicating the current length of the buffer, this value must reach the time (max value) of the buffer to start to play.
 
time:Number — A Number indicating the time of the buffer to reach in seconds (you can set this buffer time property with the SomaVideoPlayer instance property: bufferTime).
dispose()method 
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).

preloadingCallBack()method 
public function preloadingCallBack(bytesLoaded:Number, bytesTotal:Number):void

Methods called whenever the video is preloading.

Parameters
bytesLoaded:Number — A Number indicating the number of bytes loaded.
 
bytesTotal:Number — A Number indicating the total number of bytes to load.
registerPlayer()method 
public function registerPlayer(player:SomaVideoPlayer):void

Register the SomaVideoPlayer instance that will be used with the skin class

Parameters
player:SomaVideoPlayer — A SomaVideoPlayer instance.
timeCallBack()method 
public function timeCallBack(time:Number, duration:Number):void

Methods called whenever the video playhead is updated to display the current time and duration in seconds of the video.

Parameters
time:Number — A Number indicating the current time of the video playhead in seconds.
 
duration:Number — A Number indicating the duration of the video (time length) in seconds.