📄 flowplayerbase.as
字号:
/** * Copyright (c) 2008, 2009 Flowplayer Oy * * This file is part of Flowplayer. * * Flowplayer is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Flowplayer is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Flowplayer. If not, see <http://www.gnu.org/licenses/>. */package org.flowplayer.view { import org.flowplayer.config.Config; import org.flowplayer.controller.PlayListController; import org.flowplayer.controller.ResourceLoader; import org.flowplayer.controller.ResourceLoaderImpl; import org.flowplayer.flow_internal; import org.flowplayer.model.Clip; import org.flowplayer.model.DisplayPluginModel; import org.flowplayer.model.DisplayProperties; import org.flowplayer.model.EventDispatcher; import org.flowplayer.model.Loadable; import org.flowplayer.model.PlayButtonOverlay; import org.flowplayer.model.PlayerError; import org.flowplayer.model.PlayerEvent; import org.flowplayer.model.Playlist; import org.flowplayer.model.Plugin; import org.flowplayer.model.PluginFactory; import org.flowplayer.model.ProviderModel; import org.flowplayer.model.State; import org.flowplayer.model.Status; import org.flowplayer.util.Assert; import org.flowplayer.util.Log; import org.flowplayer.util.LogConfiguration; import org.flowplayer.util.TextUtil; import org.flowplayer.util.URLUtil; import org.flowplayer.view.Panel; import flash.display.DisplayObject; import flash.display.Stage; import flash.text.TextField; import flash.utils.getDefinitionByName; use namespace flow_internal; /** * @author anssi */ public class FlowplayerBase extends PlayerEventDispatcher implements ErrorHandler { protected var _playListController:PlayListController; protected var _pluginRegistry:PluginRegistry; protected var _config:Config; protected var _animationEngine:AnimationEngine; protected var _panel:Panel; private static var _instance:FlowplayerBase = null; private var _stage:Stage; private var _errorHandler:ErrorHandler; private var _fullscreenManager:FullscreenManager; private var _pluginLoader:PluginLoader; private var _playerSWFBaseURL:String; public function FlowplayerBase( stage:Stage, control:PlayListController, pluginRegistry:PluginRegistry, panel:Panel, animationEngine:AnimationEngine, errorHandler:ErrorHandler, config:Config, fullscreenManager:FullscreenManager, pluginLoader:PluginLoader, playerSWFBaseURL:String) { // dummy references to get stuff included in the lib Assert.notNull(1); URLUtil.isCompleteURLWithProtocol("foo"); var plug:Plugin; var plugFac:PluginFactory; var style:FlowStyleSheet; var styleable:StyleableSprite; var animation:Animation; if (_instance) { log.error("Flowplayer already instantiated"); throw new Error("Flowplayer already instantiated"); } _stage = stage; this._playListController = control;// registerCallbacks(); _pluginRegistry = pluginRegistry; _panel = panel; _animationEngine = animationEngine; _errorHandler = errorHandler; _config = config; _fullscreenManager = fullscreenManager; fullscreenManager.playerEventDispatcher = this; _pluginLoader = pluginLoader; _playerSWFBaseURL = playerSWFBaseURL; _instance = this; } /** * Plays the current clip in playList or the specified clip. * @param clip an optional clip to play. If specified it will replace the player's * playlist. */ public function play(clip:Clip = null):FlowplayerBase { log.debug("play(" + clip + ")"); _playListController.play(clip); return this; } /** * Starts buffering the current clip in playList. */ public function startBuffering():FlowplayerBase { log.debug("startBuffering()"); _playListController.startBuffering(); return this; } /** * Stops buffering. */ public function stopBuffering():FlowplayerBase { log.debug("stopBuffering()"); _playListController.stopBuffering(); return this; } /** * Pauses the current clip. */ public function pause():FlowplayerBase { log.debug("pause()"); _playListController.pause(); return this; } /** * Resumes playback of the current clip. */ public function resume():FlowplayerBase { log.debug("resume()"); _playListController.resume(); return this; } /** * Toggles between paused and resumed states. * @return true if the player is playing after the call, false if it's paused */ public function toggle():Boolean { log.debug("toggle()"); if (state == State.PAUSED) { resume(); return true; } else if (state == State.PLAYING) { pause(); return false; } else if (state == State.WAITING) { play(); return true; } return false; } /** * Is the player currently paused? * @return true if the player is currently in the paused state * @see #state */ public function isPaused():Boolean { return state == State.PAUSED; } /** * Is the player currently playing? * @return true if the player is currently in the playing or buffering state * @see #state */ public function isPlaying():Boolean { return state == State.PLAYING || state == State.BUFFERING; } /** * Stops the player and rewinds to the beginning of the playList. */ public function stop():FlowplayerBase { log.debug("stop()"); _playListController.stop(); return this; }
/** * Stops the player and closes the stream and connection. */
public function close():FlowplayerBase { log.debug("close()"); _playListController.close(); return this; } /** * Moves to next clip in playList. */ public function next():Clip { log.debug("next()"); return _playListController.next(false); } /** * Moves to previous clip in playList. */ public function previous():Clip { log.debug("previous()"); return _playListController.previous(); } /** * Toggles between the full-screen and normal display modeds. */ public function toggleFullscreen():FlowplayerBase { log.debug("toggleFullscreen"); if (dispatchBeforeEvent(PlayerEvent.fullscreen())) { _fullscreenManager.toggleFullscreen(); } return this; } /** * Is the volume muted? */ public function get muted():Boolean { return _playListController.muted; } /** * Sets the volume muted/unmuted. */ public function set muted(value:Boolean):void { _playListController.muted = value; } /** * Sets the volume to the specified level. * @param volume the new volume value, must be between 0 and 100 */ public function set volume(volume:Number):void { _playListController.volume = volume; } /** * Gets the current volume level. * @return the volume level percentage (0-100) */ public function get volume():Number { log.debug("get volume"); return _playListController.volume; } /** * Shows the specified plugin display object on the panel. * @param disp the display object to show * @param props the DisplayProperties to be used */ public function showPlugin(disp:DisplayObject, props:DisplayProperties = null):void { disp.alpha = props ? props.alpha : 1; disp.visible = true; props.display = "block";
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -