Fix compiler problem with ambiguous VideoEvent
[potlatch2.git] / net / systemeD / potlatch2 / help / VideoPlayer.mxml
1 <?xml version="1.0" encoding="utf-8"?>
2 <mx:VBox
3     xmlns:fx="http://ns.adobe.com/mxml/2009"
4     xmlns:mx="library://ns.adobe.com/flex/mx"
5     verticalGap="0">
6         <mx:ViewStack id="videoStack" width="100%" height="100%">
7                 <mx:Box id="previewContainer">
8                         <mx:Image id="preview" width="100%" height="100%" source="{previewImage}" 
9                                 click="playVideo()" />
10                 </mx:Box>
11                 <mx:Box id="videoContainer">
12                         <mx:VideoDisplay id="video" 
13                                 metadataReceived="prepareVideo()"
14                                 playheadUpdate="advanceProgress(event)"
15                                 click="playVideo()"
16                                 autoPlay="false"
17                                 width="100%" height="100%" />
18                 </mx:Box>
19         </mx:ViewStack>
20         <mx:HBox backgroundColor="#6495ED" width="100%" height="16"> 
21                 <mx:Image id="playButton" width="16" height="16" source="{playImage}" click="playVideo()" />
22                 <mx:HSlider width="100%" id="progressBar" liveDragging="true" 
23                         allowTrackClick="false" 
24                         thumbPress="progressThumbPress(event);" 
25                         thumbRelease="progressThumbRelease(event);" />
26         </mx:HBox> 
27
28         <fx:Script>
29                 <![CDATA[ 
30
31                         /** VideoPlayer component for P2 help dialog.
32                                 Embed like this:
33
34                                 <help:VideoPlayer width="400" height="300" 
35                                         file="videos/test.flv" 
36                                         previewImage="videos/test_preview.png" />
37                                         
38                                 previewImage is the image that will be shown in the video pane
39                                 before the user clicks 'play' - usually a still of the first frame
40                                 of the video. (This means the video file won't be downloaded unless 
41                                 the user actually wants it.)
42                         */
43
44                         [Bindable] public var file:String;
45                         [Bindable] public var previewImage:String; 
46                         private var wasPlaying:Boolean;
47
48                         [Bindable] [Embed(source="../../../../embedded/video_play.png" )] public var playImage:Class;
49                         [Bindable] [Embed(source="../../../../embedded/video_pause.png")] public var pauseImage:Class;
50
51                         public function playVideo():void {
52                                 if (videoStack.selectedChild==previewContainer) {
53                                         preview.alpha=0.5;
54                                         video.source=file;
55                                         video.play();
56                                         playButton.source=pauseImage;
57                                 } else if (video.playing) {
58                                         video.pause();
59                                         playButton.source=playImage;
60                                 } else {
61                                         video.play();
62                                         playButton.source=pauseImage;
63                                 }
64                         }
65                         public function prepareVideo():void {
66                                 videoStack.selectedChild=videoContainer;
67                                 progressBar.maximum=video.totalTime;
68                         }
69                         public function progressThumbPress(event:Event):void { 
70                                 wasPlaying=video.playing;
71                                 video.pause();
72                                 playButton.source=playImage;
73                         }
74                         public function progressThumbRelease(event:Event):void { 
75                                 video.playheadTime = event.currentTarget.value; 
76                                 if (wasPlaying) playVideo();
77                         } 
78                         public function advanceProgress(event:Event):void {
79                                 progressBar.value = mx.events.VideoEvent(event).playheadTime;
80                         }
81                         public function stopPlaying():void {
82                                 if (!video.playing) return;
83                                 video.pause();
84                                 playButton.source=playImage;
85                         }
86
87                 ]]> 
88         </fx:Script>
89 </mx:VBox>