Changeset 574
- Timestamp:
- 11/05/09 14:20:11 (4 years ago)
- Location:
- trunk/sdk
- Files:
-
- 4 edited
-
files/settings.js (modified) (1 diff)
-
players/5.0.swf (modified) (previous)
-
plugins/player5plugin/Player5Plugin.as (modified) (5 diffs)
-
plugins/player5plugin/player5plugin.swf (modified) (previous)
Legend:
- Unmodified
- Added
- Removed
-
trunk/sdk/files/settings.js
r573 r574 120 120 'player5plugin.position':'left', 121 121 'player5plugin.size':200, 122 'player5plugin.text':'Hello, world!', 122 123 height:240, 123 124 width:600 -
trunk/sdk/plugins/player5plugin/Player5Plugin.as
r573 r574 1 1 package { 2 import com.longtailvideo.jwplayer.events.MediaEvent; 3 import com.longtailvideo.jwplayer.events.PlayerStateEvent; 2 4 import com.longtailvideo.jwplayer.player.IPlayer; 5 import com.longtailvideo.jwplayer.player.PlayerState; 3 6 import com.longtailvideo.jwplayer.plugins.IPlugin; 4 7 import com.longtailvideo.jwplayer.plugins.PluginConfig; … … 6 9 import flash.display.Sprite; 7 10 import flash.events.MouseEvent; 11 import flash.text.TextField; 12 import flash.text.TextFormat; 8 13 9 14 public class Player5Plugin extends Sprite implements IPlugin { 10 15 private var api:IPlayer; 11 16 17 private var textBox:TextField; 18 private var infoBox:TextField; 19 private var clickButton:Sprite; 20 12 21 /** Let the player know what the name of your plugin is. **/ 13 22 public function get id():String { return "player5plugin"; } 23 24 /** Constructor **/ 25 public function Player5Plugin() { 26 clickButton = new Sprite(); 27 clickButton.graphics.beginFill(0x003388, 1); 28 clickButton.graphics.drawCircle(5, 5, 10); 29 clickButton.graphics.endFill(); 30 clickButton.x = 10; 31 clickButton.y = 10; 32 clickButton.buttonMode = true; 33 addChild(clickButton); 34 35 textBox = new TextField(); 36 textBox.defaultTextFormat = new TextFormat('_sans',14,0x111188,true); 37 textBox.x = 5; 38 textBox.y = 25 39 addChild(textBox); 40 41 infoBox = new TextField(); 42 infoBox.defaultTextFormat = new TextFormat('_sans', 13, 0x003311, true); 43 infoBox.x = 5; 44 infoBox.y = 45; 45 addChild(infoBox); 46 } 14 47 15 48 /** … … 22 55 api = player; 23 56 24 var clickButton:Sprite = new Sprite();25 clickButton.graphics.beginFill(0x003388, 1);26 clickButton.graphics.drawCircle(0, 0, 10);27 clickButton.graphics.endFill();28 clickButton.x = 10;29 clickButton.y = 10;30 clickButton.buttonMode = true;31 57 clickButton.addEventListener(MouseEvent.CLICK, buttonClicked); 32 addChild(clickButton); 33 58 59 textBox.text = config['text']; 60 61 api.addEventListener(MediaEvent.JWPLAYER_MEDIA_TIME, timeHandler); 62 api.addEventListener(PlayerStateEvent.JWPLAYER_PLAYER_STATE, stateHandler); 63 api.addEventListener(MediaEvent.JWPLAYER_MEDIA_COMPLETE, completeHandler); 34 64 } 65 35 66 36 67 /** … … 47 78 this.graphics.drawRect(0, 0, wid, hei); 48 79 this.graphics.endFill(); 49 50 51 80 } 52 81 … … 59 88 } 60 89 90 private function timeHandler(event:MediaEvent):void { 91 infoBox.text = Math.round(event.duration - event.position) + " seconds left"; 92 } 93 94 private function stateHandler(event:PlayerStateEvent):void { 95 switch (event.newstate) { 96 case PlayerState.PAUSED: 97 infoBox.text = 'video paused'; 98 break; 99 case PlayerState.PLAYING: 100 // nothing here, since now the time is updating. 101 break; 102 case PlayerState.IDLE: 103 infoBox.text = 'video idle'; 104 break; 105 case PlayerState.BUFFERING: 106 infoBox.text = 'video buffering'; 107 break; 108 } 109 } 110 111 private function completeHandler(evt:MediaEvent):void { 112 infoBox.text = "video complete"; 113 } 114 61 115 } 62 116 }
Note: See TracChangeset
for help on using the changeset viewer.
