Changeset 574


Ignore:
Timestamp:
11/05/09 14:20:11 (4 years ago)
Author:
pablo
Message:

Adding a sample Player 5 plugin

Location:
trunk/sdk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sdk/files/settings.js

    r573 r574  
    120120                        'player5plugin.position':'left', 
    121121                        'player5plugin.size':200, 
     122                        'player5plugin.text':'Hello, world!', 
    122123                        height:240, 
    123124                        width:600 
  • trunk/sdk/plugins/player5plugin/Player5Plugin.as

    r573 r574  
    11package { 
     2        import com.longtailvideo.jwplayer.events.MediaEvent; 
     3        import com.longtailvideo.jwplayer.events.PlayerStateEvent; 
    24        import com.longtailvideo.jwplayer.player.IPlayer; 
     5        import com.longtailvideo.jwplayer.player.PlayerState; 
    36        import com.longtailvideo.jwplayer.plugins.IPlugin; 
    47        import com.longtailvideo.jwplayer.plugins.PluginConfig; 
     
    69        import flash.display.Sprite; 
    710        import flash.events.MouseEvent; 
     11        import flash.text.TextField; 
     12        import flash.text.TextFormat; 
    813         
    914        public class Player5Plugin extends Sprite implements IPlugin { 
    1015                private var api:IPlayer; 
    1116 
     17                private var textBox:TextField; 
     18                private var infoBox:TextField; 
     19                private var clickButton:Sprite; 
     20                 
    1221                /** Let the player know what the name of your plugin is. **/ 
    1322                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                } 
    1447                 
    1548                /** 
     
    2255                        api = player; 
    2356                         
    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; 
    3157                        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);       
    3464                } 
     65                 
    3566                 
    3667                /** 
     
    4778                        this.graphics.drawRect(0, 0, wid, hei); 
    4879                        this.graphics.endFill(); 
    49                          
    50                          
    5180                } 
    5281 
     
    5988                } 
    6089                 
     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                 
    61115        } 
    62116} 
Note: See TracChangeset for help on using the changeset viewer.