Packagecom.soma.view.video.skin
Classpublic class SomaVideoPlaySkin
InheritanceSomaVideoPlaySkin Inheritance flash.display.Sprite
ImplementsISomaVideoPlaySkin

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 play/pause/stop button, 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 play/pause/stop skin. The base will be a DisplayObject class, such as Sprite, implementing ISomaVideoPlaySkin.

Custom play/pause/stop class
package {
    import com.soma.view.video.SomaVideoPlayer;
    import com.soma.view.video.skin.ISomaVideoPlaySkin;
    
    import flash.display.Sprite;
    
    public class CustomPlaySkin extends Sprite implements ISomaVideoPlaySkin {
        
        private var _player:SomaVideoPlayer;
        
        public function CustomPlaySkin() {
            createSkinElements();
        }
        
        private function createSkinElements():void {
            // create play/pause/stop buttons here and use:
            // _player.play();
            // _player.resume();
            // _player.stop();
            // _player.pause();
        }
        
        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 playCallBack():void {
            // here the controller will indicate when the video starts to play.
            trace("video is played");
        }
        
        public function pauseCallBack():void {
            // here the controller will indicate when the video is paused.
            trace("video is paused");
        }
        
        public function resumeCallBack():void {
            // here the controller will indicate when the video is resumed.
            trace("video is resumed");
        }
        
        public function stopCallBack():void {
            // here the controller will indicate when the video is stopped.
            trace("video is stopped");
        }
        
    }
}
   
Add the CustomPlaySkin to the SomaVideoControls instead of the default one:
var controls:SomaVideoControls = new SomaVideoControls();
controls.addControl(new CustomPlaySkin());
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:SomaVideoPlaySkin = player.controls.getControl(SomaVideoPlaySkin) as SomaVideoPlaySkin;
skin.backgroundColor = 0xFF0000;
skin.backgroundAlpha = .5;
     
See the SomaVideoControls documentation to add or create your own controls.

See also

Soma
SomaVideo
SomaVideoPlayer
SomaVideoEvent
SomaVideoControls
SomaVideoTimeBarSkin
SomaVideoMuteSkin
SomaVideoFullscreenSkin


Public Properties
 PropertyDefined by
  backgroundAlpha : Number
Specifies the background transparency of the skin (default alpha 0).
SomaVideoPlaySkin
  backgroundColor : uint
Specifies the background color of the skin (default is black).
SomaVideoPlaySkin
  buttonAlpha : Number
Specifies the default transparency of the buttons (default alpha 1).
SomaVideoPlaySkin
  buttonColor : uint
Specifies the default color of the buttons (default is white).
SomaVideoPlaySkin
  pauseButton : Sprite
[read-only] Get the pause button.
SomaVideoPlaySkin
  playButton : Sprite
[read-only] Get the play button.
SomaVideoPlaySkin
Public Methods
 MethodDefined by
  
Creates a SomaVideoPlaySkin instance.
SomaVideoPlaySkin
  
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).
SomaVideoPlaySkin
  
Method called whenever the video is resumed.
SomaVideoPlaySkin
  
playCallBack():void
Method called whenever the video starts to play.
SomaVideoPlaySkin
  
Register the SomaVideoPlayer instance that will be used with the skin class
SomaVideoPlaySkin
  
Method called whenever the video is stopped.
SomaVideoPlaySkin
  
stopCallBack():void
Method called whenever the video is paused.
SomaVideoPlaySkin
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
buttonAlphaproperty 
buttonAlpha:Number  [read-write]

Specifies the default transparency of the buttons (default alpha 1).

Implementation
    public function get buttonAlpha():Number
    public function set buttonAlpha(value:Number):void
buttonColorproperty 
buttonColor:uint  [read-write]

Specifies the default color of the buttons (default is white).

Implementation
    public function get buttonColor():uint
    public function set buttonColor(value:uint):void
pauseButtonproperty 
pauseButton:Sprite  [read-only]

Get the pause button.

Implementation
    public function get pauseButton():Sprite
playButtonproperty 
playButton:Sprite  [read-only]

Get the play button.

Implementation
    public function get playButton():Sprite
Constructor detail
SomaVideoPlaySkin()constructor
public function SomaVideoPlaySkin()

Creates a SomaVideoPlaySkin instance.

Method detail
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).

pauseCallBack()method 
public function pauseCallBack():void

Method called whenever the video is resumed.

playCallBack()method 
public function playCallBack():void

Method called whenever the video starts to play.

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.
resumeCallBack()method 
public function resumeCallBack():void

Method called whenever the video is stopped.

stopCallBack()method 
public function stopCallBack():void

Method called whenever the video is paused.