Package | com.myflashlab.air.extensions.player.surface |
Class | public class SurfacePlayer |
Inheritance | SurfacePlayer flash.events.EventDispatcher |
SurfacePlayer will be played using the native player on your device and it will be attached to the surface of your device which means that it will rest on top of your Air app. you certainly won't be able to draw anything over your player area. consider this fact when designing your app logic.
V3.0 of this extension supports playing video files from applicationStorageDirectory and documentsDirectory on both, Android and iOS
If you want to play an online video, you should try our other extension at http://www.myflashlabs.com/product/video-player-ane-adobe-air-native-extension/
Make sure to take care of the permissions manually if you are targeting AIR SDK 24+: https://github.com/myflashlab/surfaceVideoPlayer-ANE/#permissions
Property | Defined By | ||
---|---|---|---|
duration : int [read-only]
get the total duration of your video clip in milliseconds
| SurfacePlayer | ||
isPlaying : Boolean [read-only]
indicates if the video file is playing or if it is not
| SurfacePlayer | ||
position : int [read-only]
get the current position of your video clip in milliseconds
| SurfacePlayer | ||
videoInfo : Object [read-only]
after attaching a video, this property holds information about the current video
| SurfacePlayer | ||
volume : int
indicates the Volume property for your video player. | SurfacePlayer |
Method | Defined By | ||
---|---|---|---|
SurfacePlayer($stage:Stage)
to initialize the extension and pass in the flash stage to it
| SurfacePlayer | ||
attachVideo($file:File, $videoLocation:String):void
Attach a new video file address to your surface player. | SurfacePlayer | ||
detachVideo():void
call this method to detach the currently attached video file to release resources on your app. | SurfacePlayer | ||
dispose():void
call this method when you no longer need the player. | SurfacePlayer | ||
init($x:int, $y:int, $width:int, $height:int, $haveRatio:Boolean):void
build up the extension native part with the initial dimension settings. | SurfacePlayer | ||
isSupported():Boolean
Indicates if surface video player is supported on your device's OS version or not. | SurfacePlayer | ||
pause():void
pause your video playback
| SurfacePlayer | ||
play():void
after attaching a video, you can play it back now. | SurfacePlayer | ||
seekTo($pos:int):void
call this method to jump to different locations in your video clip. | SurfacePlayer | ||
setPosition($x:int, $y:int, $width:int, $height:int, $haveRatio:Boolean):void
Use this optimized method to set the position of your video clip inside your Air app. | SurfacePlayer | ||
stop():void
stop your video playback will move the video to position 0 in your video. | SurfacePlayer |
Constant | Defined By | ||
---|---|---|---|
EXTENSION_ID : String = com.myflashlab.air.extensions.videoPlayerSurface [static] | SurfacePlayer | ||
VERSION : String = 3.4.41 [static] | SurfacePlayer |
duration | property |
duration:int
[read-only] get the total duration of your video clip in milliseconds
public function get duration():int
isPlaying | property |
isPlaying:Boolean
[read-only] indicates if the video file is playing or if it is not
public function get isPlaying():Boolean
position | property |
position:int
[read-only] get the current position of your video clip in milliseconds
public function get position():int
videoInfo | property |
videoInfo:Object
[read-only] after attaching a video, this property holds information about the current video
public function get videoInfo():Object
volume | property |
volume:int
indicates the Volume property for your video player. you can control the volume between 0 - 100
public function get volume():int
public function set volume(value:int):void
SurfacePlayer | () | Constructor |
public function SurfacePlayer($stage:Stage)
to initialize the extension and pass in the flash stage to it
Parameters$stage:Stage |
attachVideo | () | method |
public function attachVideo($file:File, $videoLocation:String):void
Attach a new video file address to your surface player. you must specify if your video file
is in File.documentsDirectory > SurfaceVideoLocation.ON_SD_CARD
OR
File.applicationStorageDirectory > SurfaceVideoLocation.ON_APP
Parameters
$file:File | |
$videoLocation:String (default = NaN ) — Choose SurfaceVideoLocation.ON_SD_CARD if your video is in File.documentsDirectory OR set it to SurfaceVideoLocation.ON_APP if your video is in File.applicationStorageDirectory
|
See also
detachVideo | () | method |
public function detachVideo():void
call this method to detach the currently attached video file to release resources on your app.
See also
dispose | () | method |
public function dispose():void
call this method when you no longer need the player. if you want to attach a new video, please just call the detachVideo method. if you dispose the extension, you have to initialize it from the beginning! but you can detachVideo simply without having to re-initialize the whole thing again.
See also
init | () | method |
public function init($x:int, $y:int, $width:int, $height:int, $haveRatio:Boolean):void
build up the extension native part with the initial dimension settings.
Parameters
$x:int | |
$y:int | |
$width:int | |
$height:int | |
$haveRatio:Boolean |
isSupported | () | method |
public function isSupported():Boolean
Indicates if surface video player is supported on your device's OS version or not. this works on Android SDK 11 or higher and iOS 7.0 or higher
ReturnsBoolean — |
pause | () | method |
public function pause():void
pause your video playback
play | () | method |
public function play():void
after attaching a video, you can play it back now.
seekTo | () | method |
public function seekTo($pos:int):void
call this method to jump to different locations in your video clip.
Parameters
$pos:int — position of your video file in milliseconds
|
setPosition | () | method |
public function setPosition($x:int, $y:int, $width:int, $height:int, $haveRatio:Boolean):void
Use this optimized method to set the position of your video clip inside your Air app. when I say optimized, I mean that you can use this method in any Tween listener and actually animate your video clip around your Air appication!
Parameters
$x:int | |
$y:int | |
$width:int | |
$height:int | |
$haveRatio:Boolean |
stop | () | method |
public function stop():void
stop your video playback will move the video to position 0 in your video.
EXTENSION_ID | Constant |
public static const EXTENSION_ID:String = com.myflashlab.air.extensions.videoPlayerSurface
VERSION | Constant |
public static const VERSION:String = 3.4.41
import com.myflashlab.air.extensions.player.surface.SurfacePlayer; import com.myflashlab.air.extensions.player.surface.SurfacePlayerEvent; import com.myflashlab.air.extensions.player.surface.SurfaceVideoLocation; var _ex:SurfacePlayer = new SurfacePlayer(stage); // on Android, when the surface player is availble, it will hijack the device back button clicks! with the folloiwng listener you can listen to device's back button clicks _ex.addEventListener(SurfacePlayerEvent.ON_BACK_CLICKED, onBackClickedWhenSurfacePlayerIsAvailable); // dispatches when the video has reached end _ex.addEventListener(SurfacePlayerEvent.ON_COMPLETION_LISTENER, onVideoPlaybackCompleted); // when you attach a video file _ex.attachVideo(file); this listener will tell you if this file is availble or not. play your video only if it is availble _ex.addEventListener(SurfacePlayerEvent.ON_FILE_AVAILABILITY, onTargetVideoAvailability); // this listener will tell you different states that your Media is in. "STARTED", "PAUSED", "STOPPED" _ex.addEventListener(SurfacePlayerEvent.ON_MEDIA_STATUS_CHANGED, onMediaStatusChanged); // the first thing you should do is to initialize the extension with its initial parameters _ex.init(x, y, width, height, true); // the last parameter is the ratio for your video clip if false, the video will be stretched to fit your specified width and height // after initializing the extension, you need to attach a new video file to it _ex.attachVideo(File.applicationStorageDirectory.resolvePath("testVideoPlayerSurface.mp4"), SurfaceVideoLocation.ON_APP); // and finally play it! (it's a good idea to always check for SurfacePlayerEvent.ON_FILE_AVAILABILITY before playing the file) _ex.play(); // there are many other methods for you to control the video playback like pause, seek, fullscreen, set volume, etc. please study the sample demo project // coming with this extension to know how you can work with the other methods and when/how to dispose the extension properly.