Packagecom.soma.view.video
Classpublic class SomaVideo
InheritanceSomaVideo Inheritance 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

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:
SomaVideo is created to display a simple video without any controller or skins (play, volume, etc), you can access to the most basic actions on a video such as play, pause, stop, volume and so on.

var video:SomaVideo = new SomaVideo("video/video.flv");
video.addEventListener(SomaVideoEvent.METADATA_UPDATE, metadataHandler);
video.addEventListener(SomaVideoEvent.PLAYHEAD_UPDATE, playheadHandler);
addChild(video);

private function metadataHandler(e:SomaVideoEvent):void {
    trace(e.player.duration);
}

private function playheadHandler(e:SomaVideoEvent):void {
    trace(e.player.time);
}
     

See also

Soma
SomaVideo
SomaVideoPlayer
SomaVideoEvent


Public Properties
 PropertyDefined by
  bufferLength : Number
[read-only] Get the length in seconds of the buffer, the "buffer length" will reach the "buffer time" before playing the video, you can get the information on a SomaVideoEvent.BUFFERING_START, SomaVideoEvent.BUFFERING_PROGRESS and SomaVideoEvent.BUFFERING_COMPLETE event.
SomaVideo
  bufferPercentage : Number
[read-only] Get the percentage of the buffer (seconds loaded), the "buffer length" will reach the "buffer time" before playing the video, you can get the information on a SomaVideoEvent.BUFFERING_START, SomaVideoEvent.BUFFERING_PROGRESS and SomaVideoEvent.BUFFERING_COMPLETE event.
SomaVideo
  bufferTime : Number
Buffer value in seconds, the default (flash built-in default of the NetStream class) is 0.1 (tenth of a second).
SomaVideo
  bytesLoaded : Number
[read-only] Get the bytes loaded of the video (preloading), you can get the information on a SomaVideoEvent.PRELOADING_START, SomaVideoEvent.PRELOADING_PROGRESS and SomaVideoEvent.PRELOADING_COMPLETE event.
SomaVideo
  bytesTotal : Number
[read-only] Get the bytes total that the video will preload, you can get the information on a SomaVideoEvent.PRELOADING_START, SomaVideoEvent.PRELOADING_PROGRESS and SomaVideoEvent.PRELOADING_COMPLETE event.
SomaVideo
  creator : String
[read-only] Get the creator, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  duration : Number
[read-only] Get the time length (seconds) of the video, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  enableAutoResizeOnMetaData : Boolean
Whether or not the Video instance (not the SomaVideo intance) will be resized when the metadata are received, default is true.

Note: enabled or disabled will not change anything if you specified a size to the SomaVideo instance.
SomaVideo
  haskeyframes : Boolean
[read-only] Whether or not the video has keyframes, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  hasmetadata : Boolean
[read-only] Whether or not the video has metadata, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  heightVideoSource : Number
[read-only] Get the original height of the video, only available after that an event SomaVideoEvent.XMPDATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  isPlaying : Boolean
[read-only] Whether or not the video is currently playing.
SomaVideo
  keyframes : Object
[read-only] Get the video keyframes, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  lastkeyframelocation : String
[read-only] Get the last key frame location, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  lastkeyframetimestamp : Number
[read-only] Get the last keyframe timestamp, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  LOG_ERRORS : Boolean = true
[static] Indicates that the NetStatusEvent errors will be traced in the console (default true).
SomaVideo
  loop : Boolean
Specifies whether the video will replay on its own when it reaches the end.
SomaVideo
  metadatacreator : String
[read-only] Get the metadata creator, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  metaDataObject : Object
[read-only] Get the metadata object received, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  netConnection : NetConnection
[read-only] Get the NetConnection instance of the video.
SomaVideo
  pan : Number
Pan (panning) of the video, the range is -1 (for left) to 1 (for right) and the default is 0.
SomaVideo
  preloadingPercentage : Number
[read-only] Get the percentage of the video that is preloaded (0 to 100), you can get the information on a SomaVideoEvent.PRELOADING_START, SomaVideoEvent.PRELOADING_PROGRESS and SomaVideoEvent.PRELOADING_COMPLETE event.
SomaVideo
  smoothing : Boolean
Specifies whether the video should be smoothed (interpolated) when it is scaled.
SomaVideo
  sound : SoundTransform
SoundTransform instance used for the volume and panning
SomaVideo
  stream : NetStream
[read-only] Get the NetStream instance of the video.
SomaVideo
  time : Number
[read-only] Get the current position of the playhead.
SomaVideo
  url : String
[read-only] Get the url of the video.
SomaVideo
  video : Video
[read-only] Get the Video instance used to display the video.
SomaVideo
  videodatarate : Number
[read-only] Get the video data rate (kbps), only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  volume : Number
Volume of the video, the range is 0 to 1 and the default is 1.
SomaVideo
  widthVideoSource : Number
[read-only] Get the original width of the video, only available after that an event SomaVideoEvent.XMPDATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
  xmpDataObject : Object
[read-only] Get the XMP data object received, only available after that an event SomaVideoEvent.XMPDATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.
SomaVideo
Public Methods
 MethodDefined by
  
SomaVideo(url:String)
Creates a SomaVideo Instance.
SomaVideo
  
dispose():void
Call this method when you dispose a SomaVideoPlayer to remove children, event listeners or whatever that needs to be destroyed to free the memory (make the instance elligible to the Garbage Collection).
SomaVideo
  
info():String
Get information about the video.
SomaVideo
  
pause():void
Pause the video.
SomaVideo
  
play():void
Play the video.
SomaVideo
  
resume():void
Resume the video.
SomaVideo
  
seek(offset:Number):void
Move the video playhead to a (approximate) time.
SomaVideo
  
setSource(url:String):void
Set the source to play.
SomaVideo
  
stop():void
Stop the video.
SomaVideo
Property detail
bufferLengthproperty
bufferLength:Number  [read-only]

Get the length in seconds of the buffer, the "buffer length" will reach the "buffer time" before playing the video, you can get the information on a SomaVideoEvent.BUFFERING_START, SomaVideoEvent.BUFFERING_PROGRESS and SomaVideoEvent.BUFFERING_COMPLETE event.

Implementation
    public function get bufferLength():Number
bufferPercentageproperty 
bufferPercentage:Number  [read-only]

Get the percentage of the buffer (seconds loaded), the "buffer length" will reach the "buffer time" before playing the video, you can get the information on a SomaVideoEvent.BUFFERING_START, SomaVideoEvent.BUFFERING_PROGRESS and SomaVideoEvent.BUFFERING_COMPLETE event.

Implementation
    public function get bufferPercentage():Number
bufferTimeproperty 
bufferTime:Number  [read-write]

Buffer value in seconds, the default (flash built-in default of the NetStream class) is 0.1 (tenth of a second).

Implementation
    public function get bufferTime():Number
    public function set bufferTime(value:Number):void
bytesLoadedproperty 
bytesLoaded:Number  [read-only]

Get the bytes loaded of the video (preloading), you can get the information on a SomaVideoEvent.PRELOADING_START, SomaVideoEvent.PRELOADING_PROGRESS and SomaVideoEvent.PRELOADING_COMPLETE event.

Implementation
    public function get bytesLoaded():Number
bytesTotalproperty 
bytesTotal:Number  [read-only]

Get the bytes total that the video will preload, you can get the information on a SomaVideoEvent.PRELOADING_START, SomaVideoEvent.PRELOADING_PROGRESS and SomaVideoEvent.PRELOADING_COMPLETE event.

Implementation
    public function get bytesTotal():Number
creatorproperty 
creator:String  [read-only]

Get the creator, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get creator():String
durationproperty 
duration:Number  [read-only]

Get the time length (seconds) of the video, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get duration():Number
enableAutoResizeOnMetaDataproperty 
enableAutoResizeOnMetaData:Boolean  [read-write]

Whether or not the Video instance (not the SomaVideo intance) will be resized when the metadata are received, default is true.

Note: enabled or disabled will not change anything if you specified a size to the SomaVideo instance.

Implementation
    public function get enableAutoResizeOnMetaData():Boolean
    public function set enableAutoResizeOnMetaData(value:Boolean):void
haskeyframesproperty 
haskeyframes:Boolean  [read-only]

Whether or not the video has keyframes, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get haskeyframes():Boolean
hasmetadataproperty 
hasmetadata:Boolean  [read-only]

Whether or not the video has metadata, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get hasmetadata():Boolean
heightVideoSourceproperty 
heightVideoSource:Number  [read-only]

Get the original height of the video, only available after that an event SomaVideoEvent.XMPDATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get heightVideoSource():Number
isPlayingproperty 
isPlaying:Boolean  [read-only]

Whether or not the video is currently playing.

Implementation
    public function get isPlaying():Boolean
keyframesproperty 
keyframes:Object  [read-only]

Get the video keyframes, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get keyframes():Object
lastkeyframelocationproperty 
lastkeyframelocation:String  [read-only]

Get the last key frame location, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get lastkeyframelocation():String
lastkeyframetimestampproperty 
lastkeyframetimestamp:Number  [read-only]

Get the last keyframe timestamp, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get lastkeyframetimestamp():Number
LOG_ERRORSproperty 
public static var LOG_ERRORS:Boolean = true

Indicates that the NetStatusEvent errors will be traced in the console (default true).

loopproperty 
loop:Boolean  [read-write]

Specifies whether the video will replay on its own when it reaches the end.

Implementation
    public function get loop():Boolean
    public function set loop(value:Boolean):void
metadatacreatorproperty 
metadatacreator:String  [read-only]

Get the metadata creator, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get metadatacreator():String
metaDataObjectproperty 
metaDataObject:Object  [read-only]

Get the metadata object received, only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get metaDataObject():Object
netConnectionproperty 
netConnection:NetConnection  [read-only]

Get the NetConnection instance of the video.

Implementation
    public function get netConnection():NetConnection
panproperty 
pan:Number  [read-write]

Pan (panning) of the video, the range is -1 (for left) to 1 (for right) and the default is 0.

Implementation
    public function get pan():Number
    public function set pan(value:Number):void
preloadingPercentageproperty 
preloadingPercentage:Number  [read-only]

Get the percentage of the video that is preloaded (0 to 100), you can get the information on a SomaVideoEvent.PRELOADING_START, SomaVideoEvent.PRELOADING_PROGRESS and SomaVideoEvent.PRELOADING_COMPLETE event.

Implementation
    public function get preloadingPercentage():Number
smoothingproperty 
smoothing:Boolean  [read-write]

Specifies whether the video should be smoothed (interpolated) when it is scaled.

Implementation
    public function get smoothing():Boolean
    public function set smoothing(value:Boolean):void
soundproperty 
sound:SoundTransform  [read-write]

SoundTransform instance used for the volume and panning

Implementation
    public function get sound():SoundTransform
    public function set sound(value:SoundTransform):void
streamproperty 
stream:NetStream  [read-only]

Get the NetStream instance of the video.

Implementation
    public function get stream():NetStream
timeproperty 
time:Number  [read-only]

Get the current position of the playhead.

Implementation
    public function get time():Number
urlproperty 
url:String  [read-only]

Get the url of the video.

Implementation
    public function get url():String
videoproperty 
video:Video  [read-only]

Get the Video instance used to display the video.

Implementation
    public function get video():Video
videodatarateproperty 
videodatarate:Number  [read-only]

Get the video data rate (kbps), only available after that an event SomaVideoEvent.METADATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get videodatarate():Number
volumeproperty 
volume:Number  [read-write]

Volume of the video, the range is 0 to 1 and the default is 1.

Implementation
    public function get volume():Number
    public function set volume(value:Number):void
widthVideoSourceproperty 
widthVideoSource:Number  [read-only]

Get the original width of the video, only available after that an event SomaVideoEvent.XMPDATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get widthVideoSource():Number
xmpDataObjectproperty 
xmpDataObject:Object  [read-only]

Get the XMP data object received, only available after that an event SomaVideoEvent.XMPDATA_UPDATE (or SomaVideoEvent.ORIGINAL_SIZE_UPDATED) has been dispatched.

Implementation
    public function get xmpDataObject():Object
Constructor detail
SomaVideo()constructor
public function SomaVideo(url:String)

Creates a SomaVideo Instance.

Parameters
url:String — A String (URL) of the video to play.
Method detail
dispose()method
public function dispose():void

Call this method when you dispose a SomaVideoPlayer to remove children, event listeners or whatever that needs to be destroyed to free the memory (make the instance elligible to the Garbage Collection).

info()method 
public function info():String

Get information about the video.

Returns
String — A String.
pause()method 
public function pause():void

Pause the video.

play()method 
public function play():void

Play the video.

resume()method 
public function resume():void

Resume the video.

seek()method 
public function seek(offset:Number):void

Move the video playhead to a (approximate) time.

Parameters
offset:Number — The approximate time value, in seconds, to move to in a video file.
setSource()method 
public function setSource(url:String):void

Set the source to play.

var video:SomaVideo = new SomaVideo("video.flv");
video.setSource("othervideo.flv");
   

Parameters
url:String — A String (URL).
stop()method 
public function stop():void

Stop the video.