Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /NNDDv2/trunk/src/org/mineap/nndd/player/PlayerController.as

Parent Directory Parent Directory | Revision Log Revision Log


Revision 505 - (hide annotations) (download)
Sun May 1 04:35:03 2011 UTC (12 years, 11 months ago) by mineap
File size: 150270 byte(s)
公式動画再生時の投稿者名表示に対応
1 mineap 370 package org.mineap.nndd.player
2     {
3     import flash.display.Loader;
4     import flash.display.LoaderInfo;
5     import flash.display.MovieClip;
6     import flash.display.NativeWindowType;
7     import flash.display.StageDisplayState;
8 mineap 498 import flash.display.StageQuality;
9 mineap 370 import flash.events.ErrorEvent;
10     import flash.events.Event;
11     import flash.events.EventDispatcher;
12     import flash.events.HTTPStatusEvent;
13     import flash.events.IOErrorEvent;
14     import flash.events.MouseEvent;
15     import flash.events.TimerEvent;
16     import flash.filesystem.File;
17     import flash.media.SoundMixer;
18     import flash.media.SoundTransform;
19     import flash.net.URLRequest;
20     import flash.utils.Timer;
21    
22     import mx.collections.ArrayCollection;
23     import mx.controls.Alert;
24     import mx.controls.DataGrid;
25     import mx.controls.SWFLoader;
26     import mx.controls.Text;
27     import mx.controls.videoClasses.VideoError;
28 mineap 381 import mx.core.FlexGlobals;
29 mineap 370 import mx.core.Window;
30     import mx.events.AIREvent;
31     import mx.events.FlexEvent;
32     import mx.events.VideoEvent;
33     import mx.formatters.DateFormatter;
34    
35     import org.libspark.utils.ForcibleLoader;
36     import org.mineap.nicovideo4as.MyListLoader;
37     import org.mineap.nicovideo4as.WatchVideoPage;
38     import org.mineap.nicovideo4as.analyzer.GetRelationResultAnalyzer;
39     import org.mineap.nicovideo4as.loader.api.ApiGetRelation;
40     import org.mineap.nicovideo4as.model.RelationResultItem;
41     import org.mineap.nicovideo4as.util.HtmlUtil;
42     import org.mineap.nndd.Access2Nico;
43     import org.mineap.nndd.FileIO;
44     import org.mineap.nndd.LogManager;
45     import org.mineap.nndd.Message;
46     import org.mineap.nndd.NNDDDownloader;
47     import org.mineap.nndd.NNDDVideoPageWatcher;
48     import org.mineap.nndd.RenewDownloadManager;
49     import org.mineap.nndd.history.HistoryManager;
50     import org.mineap.nndd.library.ILibraryManager;
51     import org.mineap.nndd.library.LibraryManagerBuilder;
52     import org.mineap.nndd.library.LocalVideoInfoLoader;
53     import org.mineap.nndd.model.NNDDComment;
54     import org.mineap.nndd.model.NNDDVideo;
55     import org.mineap.nndd.model.PlayList;
56     import org.mineap.nndd.playList.PlayListManager;
57 mineap 381 import org.mineap.nndd.player.comment.Command;
58     import org.mineap.nndd.player.comment.CommentManager;
59     import org.mineap.nndd.player.comment.Comments;
60 mineap 370 import org.mineap.nndd.util.DateUtil;
61     import org.mineap.nndd.util.IchibaBuilder;
62     import org.mineap.nndd.util.LibraryUtil;
63     import org.mineap.nndd.util.NumberUtil;
64     import org.mineap.nndd.util.PathMaker;
65     import org.mineap.nndd.util.RelationTypeUtil;
66     import org.mineap.nndd.util.ThumbInfoAnalyzer;
67     import org.mineap.nndd.util.ThumbInfoUtil;
68     import org.mineap.nndd.util.WebServiceAccessUtil;
69     import org.mineap.util.config.ConfigIO;
70     import org.mineap.util.config.ConfigManager;
71 mineap 418 import org.osmf.events.LoadEvent;
72 mineap 403 import org.osmf.events.MediaPlayerStateChangeEvent;
73 mineap 381 import org.osmf.events.TimeEvent;
74 mineap 403 import org.osmf.media.MediaPlayerState;
75 mineap 381
76     import spark.components.VideoDisplay;
77 mineap 370
78     /**
79     * ���������������������������������������������������������������������������GUI������������������������
80     *
81 mineap 381 * @author shiraminekeisuke(MineAP)
82 mineap 370 *
83     */
84     public class PlayerController extends EventDispatcher
85     {
86    
87     public static const WINDOW_TYPE_SWF:int = 0;
88     public static const WINDOW_TYPE_FLV:int = 1;
89    
90     public static const NG_LIST_RENEW:String = "NgListRenew";
91    
92     private var commentManager:CommentManager;
93     private var comments:Comments;
94    
95     public var windowType:int = -1;
96     public var videoPlayer:VideoPlayer;
97     public var videoInfoView:VideoInfoView;
98     public var ngListManager:NGListManager;
99     public var libraryManager:ILibraryManager;
100     public var playListManager:PlayListManager;
101    
102     private var windowReady:Boolean = false;
103    
104     private var swfLoader:SWFLoader = null;
105     private var loader:Loader = null;
106     private var isMovieClipPlaying:Boolean = false;
107    
108 mineap 381 private var videoDisplay:VideoDisplay = null;
109 mineap 370
110     private var nicowariSwfLoader:SWFLoader = null;
111    
112     private var isStreamingPlay:Boolean = false;
113    
114     private var source:String = "";
115    
116     private var commentTimer:Timer = new Timer(1000/15);
117     private var commentTimerVpos:int = 0;
118    
119     private var lastSeekTime:Number = new Date().time;
120    
121     private var time:Number = 0;
122    
123     private var pausing:Boolean = false;
124    
125     private var downLoadedURL:String = null;
126    
127     private var isPlayListingPlay:Boolean = false;
128     private var playingIndex:int = 0;
129    
130     private var logManager:LogManager;
131    
132     private var mailAddress:String;
133     private var password:String;
134    
135     private var mc:MovieClip;
136     private var nicowariMC:MovieClip;
137     public var swfFrameRate:Number = 0;
138    
139     public var sliderChanging:Boolean = false;
140    
141     private var nicowariTimer:Timer;
142    
143     private var isCounted:Boolean = false;
144    
145     private var isMovieClipStopping:Boolean = false;
146    
147     public var isPlayerClosing:Boolean = false;
148    
149     public var _isEconomyMode:Boolean = false;
150    
151     private var renewDownloadManager:RenewDownloadManager;
152     private var nnddDownloaderForStreaming:NNDDDownloader;
153     private var playerHistoryManager:PlayerHistoryManager;
154     private var renewDownloadManagerForOldComment:RenewDownloadManager;
155    
156     public static const NICO_WARI_HEIGHT:int = 56;
157     public static const NICO_WARI_WIDTH:int = 544;
158    
159     public static const NICO_SWF_HEIGHT:int = 384;
160     public static const NICO_SWF_WIDTH:int = 512;
161    
162     public static const NICO_VIDEO_WINDOW_HEIGHT:int = 384;
163     public static const NICO_VIDEO_WINDOW_WIDTH:int = 544;
164     public static const NICO_VIDEO_WINDOW_WIDTH_WIDE_MODE:int = 683;
165    
166     public static const WIDE_MODE_ASPECT_RATIO:Number = 1.7;
167    
168     //������������������������������������������������������null���
169     private var playingJihou:String = null;
170    
171     private var movieEndTimer:Timer = null;
172    
173     private var isSwfConverting:Boolean = false;
174    
175     private var streamingProgressCount:int = 0;
176    
177     private var streamingProgressTimer:Timer = null;
178    
179     private var _videoID:String = null;
180    
181     private var nnddDownloaderForWatch:NNDDDownloader = null;
182    
183     private var lastFrame:int = 0;
184    
185     private var lastNicowariFrame:int = 0;
186    
187     private var myListLoader:MyListLoader = null;
188    
189     private var nicowariCloseTimer:Timer = null;
190    
191     private var configManager:ConfigManager;
192    
193     private var configIO:ConfigIO;
194    
195     private var streamingRetryCount:int = 0;
196    
197     private var nicoVideoPageGetRetryTimer:Timer;
198    
199     private var nicoVideoAccessRetryTimer:Timer;
200    
201     private var nicoRelationInfoLoader:ApiGetRelation = null;
202    
203 mineap 455 [Embed(source="/player/NNDDicons_play_20x20.png")]
204 mineap 370 private var icon_Play:Class;
205    
206 mineap 455 [Embed(source="/player/NNDDicons_pause_20x20.png")]
207 mineap 370 private var icon_Pause:Class;
208    
209 mineap 455 [Embed(source="/player/NNDDicons_stop_20x20.png")]
210 mineap 370 private var icon_Stop:Class;
211    
212    
213     /**
214     * ������������������������Player���������������PlayerController���������<br>
215     * FLV���MP4������������������������Player���SWF������������������������Player���������������<br>
216     * ���������������������������������������<br>
217     *
218     * @param mailAddress
219     * @param password
220     * @param playListManager
221     * @param videoPath
222     * @param windowType
223     * @param comments
224     * @param autoPlay
225     *
226     */
227     public function PlayerController(mailAddress:String,
228     password:String,
229     playListManager:PlayListManager,
230     videoPath:String = null,
231     windowType:int = -1,
232     comments:Comments = null,
233     autoPlay:Boolean = false)
234     {
235     this.logManager = LogManager.instance;
236     this.mailAddress = mailAddress;
237     this.password = password;
238     this.libraryManager = LibraryManagerBuilder.instance.libraryManager;
239     this.playListManager = playListManager;
240     this.videoPlayer = new VideoPlayer();
241     this.videoInfoView = new VideoInfoView();
242     this.videoInfoView.type = NativeWindowType.UTILITY;
243     ConfigManager.getInstance().reload();
244     this.videoPlayer.init(this, videoInfoView, logManager);
245     this.videoInfoView.init(this, videoPlayer, logManager);
246     this.videoPlayer.addEventListener(AIREvent.WINDOW_COMPLETE, function():void{
247     // dispatchEvent(new Event(Event.ACTIVATE));
248     videoInfoView.activate();
249     videoPlayer.activate();
250     });
251     this.ngListManager = new NGListManager(this, videoPlayer, videoInfoView, logManager);
252     if(libraryManager != null){
253     if(!this.ngListManager.loadNgList(LibraryManagerBuilder.instance.libraryManager.systemFileDir)){
254     this.ngListManager.loadNgList(LibraryManagerBuilder.instance.libraryManager.libraryDir);
255     }
256     }
257     this.commentTimer.addEventListener(TimerEvent.TIMER, commentTimerHandler);
258     this.commentManager = new CommentManager(videoPlayer, videoInfoView, this);
259     if(videoPath != null && windowType != -1 && comments != null){
260     this.init(videoPath, windowType, comments, PathMaker.createThmbInfoPathByVideoPath(videoPath), autoPlay);
261     this.windowReady = true;
262     }
263     this.playerHistoryManager = new PlayerHistoryManager();
264    
265     }
266    
267     /**
268     * ���������������������������
269     * Comments���NgList���null���������������GC������������������
270     *
271     */
272     public function destructor():void{
273    
274     isMovieClipStopping = false;
275    
276     if(this.movieEndTimer != null){
277     this.movieEndTimer.stop();
278     this.movieEndTimer = null;
279     }
280    
281     if(this.commentTimer != null){
282     this.commentTimer.stop();
283     this.commentTimer.reset()
284     }else{
285     this.commentTimer = new Timer(1000/15);
286     this.commentTimer.addEventListener(TimerEvent.TIMER, commentTimerHandler);
287     }
288    
289     if(this.comments != null){
290     this.comments.destructor();
291     }
292     this.comments = null;
293     // this.ngList = null;
294    
295     if(videoDisplay != null){
296     try{
297     videoDisplay.stop();
298     }catch(error:VideoError){
299     trace(error.getStackTrace());
300     }
301     removeVideoDisplayEventListeners(videoDisplay);
302     videoDisplay.source = null;
303     videoDisplay = null;
304     this.videoPlayer.canvas_video.removeAllChildren();
305     }
306    
307     isMovieClipPlaying = false;
308     if(loader != null && !isSwfConverting){
309     SoundMixer.stopAll();
310     loader.unloadAndStop(true);
311     // removeMovieClipEventHandlers(loader);
312     loader = null;
313     this.videoPlayer.canvas_video.removeAllChildren();
314     isSwfConverting = false;
315     }
316     if(swfLoader != null && !isSwfConverting){
317     SoundMixer.stopAll();
318     swfLoader.unloadAndStop(true);
319     swfLoader = null;
320     this.videoPlayer.canvas_video.removeAllChildren();
321     isSwfConverting = false;
322     }
323    
324     if(this.nicowariSwfLoader != null){
325     videoPlayer.canvas_nicowari.removeAllChildren();
326     if(nicowariMC != null){
327     this.pauseByNicowari(true);
328     }
329     }
330    
331     if(videoPlayer != null && videoPlayer.canvas_nicowari != null){
332     videoPlayer.canvas_nicowari.removeAllChildren();
333     videoPlayer.canvas_nicowari.setConstraintValue("backgroundColor", new int("0x969696"));
334    
335     }
336    
337     if(streamingProgressTimer != null){
338     streamingProgressTimer.stop();
339     streamingProgressTimer = null;
340     }
341     streamingProgressCount = 0;
342    
343     playingJihou = null;
344    
345     if(nnddDownloaderForWatch != null){
346     nnddDownloaderForWatch.close(false, false);
347     nnddDownloaderForWatch = null;
348     }
349    
350     if(myListLoader != null){
351     myListLoader.close();
352     myListLoader = null;
353     }
354    
355     this.lastFrame = 0;
356     this.lastNicowariFrame = 0;
357    
358 mineap 490 if(videoInfoView != null){
359     videoInfoView.pubUserLinkButtonText = "(���������)";
360     videoInfoView.pubUserNameIconUrl = null;
361     videoInfoView.pubUserName = "(���������)";
362    
363     if(videoInfoView.pubUserLinkButton != null){
364     videoInfoView.pubUserLinkButton.label = videoInfoView.pubUserLinkButtonText;
365     videoInfoView.image_pubUserIcon.source = videoInfoView.pubUserNameIconUrl;
366     videoInfoView.label_pubUserName.text = videoInfoView.pubUserName;
367     }
368     }
369    
370 mineap 370 isCounted = false;
371    
372     }
373    
374     /**
375     * ������������������������Player���������������������������<br>
376     * autoPlay���true������������������������init()���������������������������������������������������������������<br>
377     * <b>playMovie()���������������������������</b>
378     *
379     * @param videoPath
380     * @param windowType
381     * @param comments
382     * @param thumbInfoPath
383     * @param ngList
384     * @param autoPlay
385     * @param isStreamingPlay
386     * @param downLoadedURL
387     * @param isPlayListingPlay
388     *
389     */
390     private function init(videoPath:String, windowType:int, comments:Comments, thumbInfoPath:String,
391     autoPlay:Boolean = false, isStreamingPlay:Boolean = false,
392     downLoadedURL:String = null, isPlayListingPlay:Boolean = false, videoId:String = ""):void
393     {
394     this.destructor();
395    
396     if(videoPlayer != null){
397     videoPlayer.resetInfo();
398     if(videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){
399     videoPlayer.restore();
400     }
401     }
402    
403     if(videoInfoView != null){
404     videoInfoView.resetInfo();
405     videoInfoView.restore();
406     }
407    
408     videoPlayer.setControllerEnable(false);
409    
410     this._videoID = null;
411     if(videoId != null && videoId != ""){
412     this._videoID = videoId;
413     }
414    
415     this.windowReady = false;
416     this.source = videoPath;
417     this.comments = comments;
418     this.time = (new Date).time;
419     this.isStreamingPlay = isStreamingPlay;
420     this.downLoadedURL = downLoadedURL;
421     this.isPlayListingPlay = isPlayListingPlay;
422     this.windowType = windowType;
423    
424     if(!isPlayListingPlay){
425     this.videoInfoView.resetPlayList();
426     }
427    
428     this.videoPlayer.videoController.resetAlpha(true);
429    
430     if(isStreamingPlay){
431     if(streamingProgressTimer != null){
432     streamingProgressTimer.stop();
433     streamingProgressTimer = null;
434     }
435     streamingProgressCount = 0;
436    
437     this.videoPlayer.label_playSourceStatus.text = "Streaming:0% ";
438 mineap 484 videoInfoView.connectionType = "Streaming";
439 mineap 370 streamingProgressTimer = new Timer(200);
440     streamingProgressTimer.addEventListener(TimerEvent.TIMER, streamingProgressHandler);
441     streamingProgressTimer.start();
442    
443     if(this.videoPlayer.title == null){
444     this.videoPlayer.addEventListener(FlexEvent.CREATION_COMPLETE, function():void{
445     this.videoPlayer.title = downLoadedURL.substr(downLoadedURL.lastIndexOf("/") + 1);
446     });
447     }else{
448     this.videoPlayer.title = downLoadedURL.substr(downLoadedURL.lastIndexOf("/") + 1);
449     }
450     }else{
451     this.videoPlayer.label_playSourceStatus.text = "[Local]";
452 mineap 484 videoInfoView.connectionType = "Local";
453 mineap 370 this.streamingRetryCount = 0;
454     if(this.videoPlayer.title == null){
455     this.videoPlayer.addEventListener(FlexEvent.CREATION_COMPLETE, function():void{
456     this.videoPlayer.title = videoPath.substr(videoPath.lastIndexOf("/") + 1);
457     });
458     }else{
459     this.videoPlayer.title = videoPath.substr(videoPath.lastIndexOf("/") + 1);
460     }
461     var file:File = new File(videoPath);
462     if(!file.exists){
463     Alert.show("������������������������������������\n������������������������������������������������������������������������������", "���������");
464     logManager.addLog("������������������������������������������������������������������������������������������������������������������:" + file.nativePath);
465 mineap 381 FlexGlobals.topLevelApplication.activate();
466 mineap 370 return;
467     }
468    
469     }
470    
471     /* ������������������������������������������������������������������������ */
472     if(!isStreamingPlay && this.videoInfoView.isRenewCommentEachPlay){
473     //���������������������������������������������������������������
474    
475     logManager.addLog(Message.START_PLAY_EACH_COMMENT_DOWNLOAD);
476     videoPlayer.label_downloadStatus.text = Message.START_PLAY_EACH_COMMENT_DOWNLOAD;
477    
478     if(this._videoID == null){
479     this._videoID = PathMaker.getVideoID(videoPath);
480     }
481    
482     if(this._videoID != null && PathMaker.getVideoID(videoPath) == LibraryUtil.getVideoKey(videoPath)){
483    
484     if((mailAddress != null && password != null) && (mailAddress != "" && password != null && password != "")){
485    
486     /* ������������������������������������������������ */
487    
488     var videoUrl:String = "http://www.nicovideo.jp/watch/"+PathMaker.getVideoID(this._videoID);
489    
490     renewCommentAtStart(PathMaker.getVideoID(this._videoID), videoPath, initStart);
491    
492     }else{
493    
494     /* ��������������������������������������������������� */
495     logManager.addLog(Message.FAIL_PLAY_EACH_COMMENT_DOWNLOAD + "(������������������������������)");
496     initStart();
497    
498     }
499    
500     }else{
501    
502     logManager.addLog(Message.FAIL_PLAY_EACH_COMMENT_DOWNLOAD + "(������ID���������������������)");
503     videoPlayer.label_downloadStatus.text = Message.FAIL_PLAY_EACH_COMMENT_DOWNLOAD + "(������ID���������������������)";
504    
505     var timer:Timer = new Timer(1000, 1);
506     timer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:TimerEvent):void{
507     initStart();
508    
509     timer.stop();
510     timer = null;
511    
512     });
513     timer.start();
514    
515     }
516     }else{
517     //���������������������������������������������������(������������������������������������������������)
518    
519     this._videoID = videoId;
520    
521     if(this._videoID == null || this._videoID == ""){
522     this._videoID = PathMaker.getVideoID(videoPlayer.title);
523     }
524    
525     logManager.addLog("���������������������������������������:" + this._videoID);
526    
527     if(this._videoID != null && this._videoID != ""){
528    
529     if(this.mailAddress != null && this.mailAddress != "" &&
530     this.password != null && this.password != ""){
531    
532     myListGroupUpdate(PathMaker.getVideoID(this._videoID));
533    
534     }else{
535     //���������������������������������
536     logManager.addLog("���������������������������������������(���������������������������)");
537     }
538    
539     }else{
540     //
541     logManager.addLog("���������������������������������������(������ID���������������������)");
542     }
543    
544     initStart();
545     }
546    
547     /**
548     * ������������������������������������������������������������
549     */
550     function initStart():void{
551    
552 mineap 498 trace(videoPlayer.stage.quality);
553    
554 mineap 370 try{
555     if(_isEconomyMode){
556     videoPlayer.label_economyStatus.text = "������������������������";
557     }else{
558     videoPlayer.label_economyStatus.text = "";
559     }
560    
561     videoPlayer.canvas_video.toolTip = null;
562    
563     if(isPlayerClosing){
564     stop();
565     destructor();
566     return;
567     }
568    
569     commentTimerVpos = 0;
570    
571     var text:Text = new Text();
572     text.text = "������������������������������������������������������������������������������������������������\n������������������������������������������������������������������";
573     text.setConstraintValue("left", 10);
574     text.setConstraintValue("top", 10);
575     videoPlayer.canvas_nicowari.addChild(text);
576    
577     videoPlayer.label_downloadStatus.text = "";
578     videoInfoView.image_thumbImg.source = "";
579     videoPlayer.videoInfoView.text_info.htmlText ="(������������������������)<br />(������������������������)<br />������: ������������: ���������������:"
580    
581     if(isStreamingPlay){
582     //������������������DL������������������������������
583     setInfo(downLoadedURL, thumbInfoPath, thumbInfoPath.substring(0, thumbInfoPath.lastIndexOf("/")) + "/nndd[IchibaInfo].html", true);
584    
585     videoInfoView.image_thumbImg.source = thumbInfoPath.substring(0, thumbInfoPath.lastIndexOf("/")) + "/nndd[ThumbImg].jpeg";
586     }else{
587     setInfo(videoPath, thumbInfoPath, PathMaker.createNicoIchibaInfoPathByVideoPath(videoPath), false);
588    
589     var nnddVideo:NNDDVideo = libraryManager.isExist(PathMaker.getVideoID(videoPath));
590    
591     if(nnddVideo != null){
592     videoInfoView.image_thumbImg.source = nnddVideo.thumbUrl;
593     }
594     }
595    
596     changeFps(videoInfoView.fps);
597    
598     videoPlayer.videoController.label_time.text = "0:00/0:00";
599     videoPlayer.videoController_under.label_time.text = "0:00/0:00";
600    
601     if(videoInfoView.isShowAlwaysNicowariArea){
602     //������������������������������������
603     videoPlayer.showNicowariArea();
604    
605     }else{
606     //���������������������������������
607     videoPlayer.hideNicowariArea();
608    
609     }
610    
611    
612     var video:NNDDVideo = libraryManager.isExist(LibraryUtil.getVideoKey(_videoID));
613     if(video != null){
614     HistoryManager.instance.addVideoByNNDDVideo(video);
615     }else{
616     video = new NNDDVideo("http://www.nicovideo.jp/watch/" + PathMaker.getVideoID(_videoID), videoPlayer.title, false, null, null, null, PathMaker.getThumbImgUrl(PathMaker.getVideoID(_videoID)));
617    
618     HistoryManager.instance.addVideoByNNDDVideo(video, null, false);
619     }
620    
621     if(windowType == PlayerController.WINDOW_TYPE_FLV){
622     //WINDOW_TYPE_FLV���������������������������������
623    
624     isMovieClipPlaying = false;
625    
626 mineap 381 videoDisplay = new VideoDisplay();
627 mineap 370
628     videoPlayer.label_downloadStatus.text = "";
629    
630     if(isStreamingPlay){
631     videoPlayer.label_downloadStatus.text = "���������������...";
632 mineap 403 videoDisplay.addEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, mediaPlayerStateChanged);
633 mineap 370 }
634    
635     videoPlayer.canvas_video.removeAllChildren();
636     videoPlayer.canvas_video.addChild(videoDisplay);
637    
638     videoDisplay.setConstraintValue("bottom", 0);
639     videoDisplay.setConstraintValue("left", 0);
640     videoDisplay.setConstraintValue("right", 0);
641     videoDisplay.setConstraintValue("top", 0);
642 mineap 381 // videoDisplay.bufferTime = 3;
643 mineap 484
644     if(videoPath.length > 4 && videoPath.substr(0,4) == "http"){
645     videoInfoView.videoServerUrl = videoPath.substring(0, videoPath.lastIndexOf("/"));
646     }else{
647     videoInfoView.videoServerUrl = videoPath;
648 mineap 490 var messageServerUrl:String = PathMaker.createNomalCommentPathByVideoPath(videoPath);
649     if(messageServerUrl != null){
650     videoInfoView.messageServerUrl = messageServerUrl;
651     }
652 mineap 484 }
653     videoInfoView.videoType = "FLV/MP4";
654    
655 mineap 370 videoDisplay.autoPlay = autoPlay;
656     videoDisplay.source = videoPath;
657     videoDisplay.autoRewind = false;
658     videoDisplay.volume = videoPlayer.videoController.slider_volume.value;
659     videoPlayer.videoController_under.slider_volume.value = videoPlayer.videoController.slider_volume.value;
660    
661     addVideoDisplayEventListeners(videoDisplay);
662    
663     commentManager.initComment(comments, videoPlayer.canvas_video);
664     commentManager.setCommentAlpha(videoInfoView.commentAlpha/100);
665    
666     windowReady = true;
667    
668     if(autoPlay && !isStreamingPlay){
669     time = (new Date).time;
670     commentTimer.start();
671     }
672    
673 mineap 418 videoDisplay.addEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
674     videoDisplay.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
675 mineap 370 videoDisplay.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void{
676     event.currentTarget.setFocus();
677     });
678    
679     videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
680     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
681     setVolume(videoPlayer.videoController.slider_volume.value);
682    
683     if(videoInfoView.visible){
684     videoInfoView.restore();
685     }
686     if(videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){
687     videoPlayer.restore();
688     }
689    
690     if(videoInfoView.visible){
691     videoInfoView.activate();
692     }
693     videoPlayer.activate();
694    
695     windowResized(false);
696    
697     videoPlayer.setControllerEnable(true);
698    
699     }else if(windowType == PlayerController.WINDOW_TYPE_SWF){
700     //WINODW_TYPE_SWF���������������������������������
701    
702     isMovieClipPlaying = true;
703     isSwfConverting = true;
704    
705     videoPlayer.label_downloadStatus.text = "SWF������������������������...";
706    
707     loader = new Loader();
708     loader.contentLoaderInfo.addEventListener(Event.COMPLETE, convertCompleteHandler);
709     var fLoader:ForcibleLoader = new ForcibleLoader(loader);
710     swfLoader = new SWFLoader();
711     swfLoader.addChild(loader);
712    
713     videoPlayer.canvas_video.removeAllChildren();
714     videoPlayer.canvas_video.addChild(swfLoader);
715    
716     swfLoader.setConstraintValue("bottom", 0);
717     swfLoader.setConstraintValue("left", 0);
718     swfLoader.setConstraintValue("right", 0);
719     swfLoader.setConstraintValue("top", 0);
720    
721     swfLoader.addEventListener(MouseEvent.CLICK, function(event:MouseEvent):void{
722     event.currentTarget.setFocus();
723     });
724    
725     commentManager.initComment(comments, videoPlayer.canvas_video);
726     commentManager.setCommentAlpha(videoInfoView.commentAlpha/100);
727    
728     windowReady = true;
729    
730 mineap 484 if(videoPath.length > 4 && videoPath.substr(0,4) == "http"){
731     videoInfoView.videoServerUrl = videoPath.substring(0, videoPath.lastIndexOf("/"));
732     }else{
733     videoInfoView.videoServerUrl = videoPath;
734 mineap 490 var messageServerUrl:String = PathMaker.createNomalCommentPathByVideoPath(videoPath);
735     if(messageServerUrl != null){
736     videoInfoView.messageServerUrl = messageServerUrl;
737     }
738 mineap 484 }
739     videoInfoView.videoType = "SWF";
740 mineap 370 if(autoPlay){
741     fLoader.load(new URLRequest(videoPath));
742     }
743    
744     var timer:Timer = new Timer(500, 4);
745     timer.addEventListener(TimerEvent.TIMER, function():void{
746     windowResized(false);
747     });
748     timer.start();
749    
750     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
751     videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
752    
753     if(videoInfoView.visible){
754     videoInfoView.restore();
755     }
756    
757     if(videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){
758     videoPlayer.restore();
759     }
760    
761     if(videoInfoView.visible){
762     videoInfoView.activate();
763     }
764     videoPlayer.activate();
765    
766     videoPlayer.setControllerEnable(true);
767    
768     }
769    
770     if(videoInfoView != null && videoInfoView.tabNavigator_comment != null){
771     if(videoInfoView.tabNavigator_comment.selectedIndex == 1){
772     // ���������������������������������������������������������������������������������
773     videoInfoView.reloadOldComment();
774     }else{
775     // ������������������������������������������������������
776     videoInfoView.resetOldCommentDate();
777     }
778     }
779    
780     return;
781     }catch(error:Error){
782     trace(error.getStackTrace());
783     logManager.addLog(error + ":" + error.getStackTrace());
784     // destructor();
785     }
786    
787     }
788    
789     }
790    
791     /**
792 mineap 441 * ���������������������������������������
793 mineap 370 *
794     * @param videoId
795     * @param videoPath
796     * @param initStart
797     *
798     */
799     private function renewCommentAtStart(videoId:String, videoPath:String, initStart:Function):void{
800    
801     var videoName:String = PathMaker.getVideoName(videoPath);
802    
803     if(renewDownloadManager != null){
804     renewDownloadManager.close();
805     renewDownloadManager = null;
806     }
807    
808     renewDownloadManager = new RenewDownloadManager(null, logManager);
809     renewDownloadManager.addEventListener(RenewDownloadManager.PROCCESS_COMPLETE, function(event:Event):void{
810     var video:NNDDVideo = libraryManager.isExist(PathMaker.getVideoID(videoPath));
811     if(video == null){
812     try{
813     video = new LocalVideoInfoLoader().loadInfo(videoPath);
814     video.creationDate = new File(videoPath).creationDate;
815     video.modificationDate = new File(videoPath).modificationDate;
816     }catch(error:Error){
817     video = new NNDDVideo(videoPath);
818     }
819     libraryManager.add(video, false);
820     video = libraryManager.isExist(video.key);
821     }
822     var thumbUrl:String = (event.currentTarget as RenewDownloadManager).localThumbUri;
823     var isLocal:Boolean = false;
824     try{
825     //������������������������������������������������������������������������������������
826     var file:File = new File(video.thumbUrl);
827     if(file.exists){
828     isLocal = true;
829     }
830     }catch(e:Error){
831     trace(e);
832     }
833    
834     //thumbUrl���URL���������������������������������������������������
835     if(!isLocal){
836     if(thumbUrl != null){
837     //���������������������thumbUrl���������
838     video.thumbUrl = thumbUrl;
839     }else if (video.thumbUrl == null || video.thumbUrl == ""){
840     //thumbUrl���������������==������������������
841     var videoId:String = PathMaker.getVideoID(_videoID);
842     if(videoId != null){
843     video.thumbUrl = PathMaker.getThumbImgUrl(videoId);
844     }else{
845     video.thumbUrl = "";
846     }
847     }
848     }
849    
850     libraryManager.update(video, false);
851    
852     var commentPath:String = PathMaker.createNomalCommentPathByVideoPath(video.getDecodeUrl());
853     var ownerCommentPath:String = PathMaker.createOwnerCommentPathByVideoPath(video.getDecodeUrl());
854     comments = new Comments(commentPath, ownerCommentPath, getCommentListProvider(), getOwnerCommentListProvider(),
855     ngListManager, videoInfoView.isShowOnlyPermissionComment, videoInfoView.isHideSekaShinComment,
856     videoInfoView.showCommentCount, videoInfoView.isNgUpEnable);
857    
858     renewDownloadManager = null;
859    
860     myListGroupUpdate(PathMaker.getVideoID(_videoID));
861    
862     initStart();
863     });
864     renewDownloadManager.addEventListener(NNDDDownloader.COMMENT_GET_SUCCESS, getProgressListener);
865     renewDownloadManager.addEventListener(NNDDDownloader.GETFLV_API_ACCESS_SUCCESS, getProgressListener);
866     renewDownloadManager.addEventListener(NNDDDownloader.ICHIBA_INFO_GET_SUCCESS, getProgressListener);
867     renewDownloadManager.addEventListener(NNDDDownloader.LOGIN_SUCCESS, getProgressListener);
868     renewDownloadManager.addEventListener(NNDDDownloader.NICOWARI_GET_SUCCESS, getProgressListener);
869     renewDownloadManager.addEventListener(NNDDDownloader.OWNER_COMMENT_GET_SUCCESS, getProgressListener);
870     renewDownloadManager.addEventListener(NNDDDownloader.THUMB_IMG_GET_SUCCESS, getProgressListener);
871     renewDownloadManager.addEventListener(NNDDDownloader.THUMB_INFO_GET_SUCCESS, getProgressListener);
872     renewDownloadManager.addEventListener(NNDDDownloader.VIDEO_GET_SUCCESS, getProgressListener);
873     renewDownloadManager.addEventListener(NNDDDownloader.WATCH_SUCCESS, getProgressListener);
874     renewDownloadManager.addEventListener(NNDDDownloader.DOWNLOAD_PROCESS_COMPLETE, getProgressListener);
875    
876     renewDownloadManager.addEventListener(NNDDDownloader.COMMENT_GET_FAIL, getFailListener);
877     renewDownloadManager.addEventListener(NNDDDownloader.GETFLV_API_ACCESS_FAIL, getFailListener);
878     renewDownloadManager.addEventListener(NNDDDownloader.ICHIBA_INFO_GET_FAIL, getFailListener);
879     renewDownloadManager.addEventListener(NNDDDownloader.LOGIN_FAIL, getFailListener);
880     renewDownloadManager.addEventListener(NNDDDownloader.NICOWARI_GET_FAIL, getFailListener);
881     renewDownloadManager.addEventListener(NNDDDownloader.OWNER_COMMENT_GET_FAIL, getFailListener);
882     renewDownloadManager.addEventListener(NNDDDownloader.THUMB_IMG_GET_FAIL, getFailListener);
883     renewDownloadManager.addEventListener(NNDDDownloader.THUMB_INFO_GET_FAIL, getFailListener);
884     renewDownloadManager.addEventListener(NNDDDownloader.VIDEO_GET_FAIL, getFailListener);
885     renewDownloadManager.addEventListener(NNDDDownloader.WATCH_FAIL, getFailListener);
886    
887     renewDownloadManager.addEventListener(RenewDownloadManager.PROCCESS_FAIL, function(event:Event):void{
888     renewDownloadManager = null;
889     videoPlayer.label_downloadStatus.text = Message.FAIL_PLAY_EACH_COMMENT_DOWNLOAD;
890     logManager.addLog(Message.FAIL_PLAY_EACH_COMMENT_DOWNLOAD);
891    
892     var timer:Timer = new Timer(1000, 1);
893     timer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
894     myListGroupUpdate(PathMaker.getVideoID(_videoID));
895     initStart();
896     });
897     timer.start();
898     });
899     renewDownloadManager.addEventListener(RenewDownloadManager.PROCCESS_CANCEL, function(event:Event):void{
900     renewDownloadManager = null;
901     videoPlayer.label_downloadStatus.text = Message.PLAY_EACH_COMMENT_DOWNLOAD_CANCEL;
902     logManager.addLog(Message.PLAY_EACH_COMMENT_DOWNLOAD_CANCEL);
903    
904     var timer:Timer = new Timer(1000, 1);
905     timer.addEventListener(TimerEvent.TIMER_COMPLETE, function():void{
906     myListGroupUpdate(PathMaker.getVideoID(_videoID));
907     initStart();
908     });
909     timer.start();
910     });
911    
912     if(this.videoInfoView.isRenewOtherCommentWithCommentEachPlay){
913     renewDownloadManager.renewForOtherVideo(this.mailAddress,
914     this.password, PathMaker.getVideoID(videoId), videoName,
915     new File(videoPath.substring(0, videoPath.lastIndexOf("/")+1)),
916 mineap 381 videoInfoView.isAppendComment, null, (FlexGlobals.topLevelApplication as NNDD).getSaveCommentMaxCount());
917 mineap 370 }else{
918     renewDownloadManager.renewForCommentOnly(this.mailAddress,
919     this.password, PathMaker.getVideoID(videoId), videoName,
920     new File(videoPath.substring(0, videoPath.lastIndexOf("/")+1)),
921 mineap 381 videoInfoView.isAppendComment, null, (FlexGlobals.topLevelApplication as NNDD).getSaveCommentMaxCount());
922 mineap 370 }
923     }
924    
925     /**
926     * ���������������������������������
927     * @param date
928     *
929     */
930     public function getOldCommentFromNico(date:Date):void{
931    
932     if(renewDownloadManagerForOldComment != null){
933     // ���������������������������
934     renewDownloadManagerForOldComment.close();
935     renewDownloadManagerForOldComment = null;
936     videoInfoView.button_oldComment_reloadFromNico.label = "������(������������������)";
937     logManager.addLog("���������������������������������");
938    
939     }else{
940     // ������������
941    
942     videoInfoView.button_oldComment_reloadFromNico.label = "���������������";
943     logManager.addLog("������������������������������:" + DateUtil.getDateString(date));
944    
945     renewDownloadManagerForOldComment = new RenewDownloadManager(null, LogManager.instance);
946     renewDownloadManagerForOldComment.addEventListener(NNDDDownloader.GETWAYBACKKEY_API_ACCESS_FAIL, function(event:Event):void{
947     videoInfoView.button_oldComment_reloadFromNico.label = "������(������������������)";
948     logManager.addLog("������������������������������:" + event);
949    
950 mineap 381 FlexGlobals.topLevelApplication.activate();
951 mineap 370 Alert.show("���������������������������������������������\n���������������������������������������������������������������������������������������������\n(���������������������������������������������������������������������������)", Message.M_ERROR);
952     });
953     renewDownloadManagerForOldComment.addEventListener(RenewDownloadManager.PROCCESS_CANCEL, function(event:Event):void{
954     videoInfoView.button_oldComment_reloadFromNico.label = "������(������������������)";
955     logManager.addLog("���������������������������������������:" + event);
956    
957     renewDownloadManagerForOldComment = null;
958     });
959     renewDownloadManagerForOldComment.addEventListener(RenewDownloadManager.PROCCESS_COMPLETE, function(event:Event):void{
960     logManager.addLog("������������������������������:" + event);
961     //������������������������������
962     reloadLocalComment(date);
963    
964     renewDownloadManagerForOldComment.close();
965     renewDownloadManagerForOldComment = null;
966    
967     videoInfoView.button_oldComment_reloadFromNico.label = "������(������������������)";
968    
969     });
970     renewDownloadManagerForOldComment.addEventListener(RenewDownloadManager.PROCCESS_FAIL, function(event:Event):void{
971     videoInfoView.button_oldComment_reloadFromNico.label = "������(������������������)";
972     logManager.addLog("������������������������������:" + event);
973    
974     renewDownloadManagerForOldComment = null;
975    
976 mineap 381 FlexGlobals.topLevelApplication.activate();
977 mineap 370 Alert.show("���������������������������������������������", Message.M_ERROR);
978     });
979    
980     var videoId:String = PathMaker.getVideoID(this._videoID);
981     var videoName:String = null;
982     var videoPath:File = null;
983     if(isStreamingPlay){
984     videoName = "nndd.flv";
985     videoPath = LibraryManagerBuilder.instance.libraryManager.tempDir;
986     }else{
987     videoName = PathMaker.getVideoName(this.source);
988     videoPath = new File(this.source.substring(0, this.source.lastIndexOf("/")+1))
989     }
990    
991     // maxCount���������������������������������������������������������������������������������������������
992 mineap 381 var maxCount:Number = (FlexGlobals.topLevelApplication as NNDD).getSaveCommentMaxCount();
993 mineap 370 if(maxCount < 10000){
994     maxCount = 10000;
995     }
996    
997     // ���������������������������������������������������������������������
998     renewDownloadManagerForOldComment.renewForCommentOnly(this.mailAddress,
999     this.password, videoId, videoName, videoPath, true,
1000     date, maxCount);
1001    
1002     }
1003    
1004     }
1005    
1006     /**
1007     *
1008     * @param event
1009     *
1010     */
1011 mineap 418 protected function byteloadedChangedEventHandler(event:Event):void{
1012 mineap 370 trace(event.type);
1013     if(videoInfoView.isResizePlayerEachPlay){
1014     resizePlayerJustVideoSize(videoPlayer.nowRatio);
1015     }else{
1016     resizePlayerJustVideoSize();
1017     }
1018     }
1019    
1020     /**
1021     *
1022 mineap 418 * @param event
1023     *
1024     */
1025     protected function osmfCurrentTimeChangeEventHandler(event:TimeEvent):void{
1026     trace(event.type + ", time:" + event.time);
1027     if(event.time < 0){
1028     return;
1029     }
1030     if(videoInfoView.isResizePlayerEachPlay){
1031     resizePlayerJustVideoSize(videoPlayer.nowRatio);
1032     }else{
1033     resizePlayerJustVideoSize();
1034     }
1035     }
1036    
1037     /**
1038     *
1039 mineap 370 * @param videoId
1040     * @return
1041     *
1042     */
1043     public function myListGroupUpdate(videoId:String):void{
1044    
1045     myListLoader = new MyListLoader();
1046     myListLoader.addEventListener(MyListLoader.GET_MYLISTGROUP_SUCCESS, function(event:Event):void{
1047     var myLists:Array = myListLoader.getMyLists();
1048    
1049     if(myLists.length > 0){
1050     var myListNames:Array = new Array();
1051     var myListIds:Array = new Array();
1052    
1053     for each(var array:Array in myLists){
1054     myListNames.push(array[0]);
1055     myListIds.push(array[1]);
1056     }
1057    
1058     videoInfoView.setMyLists(myListNames, myListIds);
1059     }
1060     myListLoader.close();
1061     });
1062     myListLoader.addEventListener(MyListLoader.GET_MYLISTGROUP_FAILURE, function(event:ErrorEvent):void{
1063     myListLoader.close();
1064     logManager.addLog("���������������������������������������:" + event + ":" + event.text);
1065     });
1066     myListLoader.getMyListGroup(videoId);
1067    
1068     }
1069    
1070    
1071     /**
1072     *
1073     * @param event
1074     *
1075     */
1076 mineap 403 private function mediaPlayerStateChanged(event:MediaPlayerStateChangeEvent):void
1077     {
1078 mineap 370 if(videoDisplay != null && !isPlayerClosing){
1079 mineap 403 if(event.state != MediaPlayerState.BUFFERING){
1080 mineap 370 videoPlayer.label_downloadStatus.text = "";
1081 mineap 403 videoDisplay.removeEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, mediaPlayerStateChanged);
1082 mineap 370 if(commentTimer != null && !commentTimer.running){
1083     time = (new Date).time;
1084     commentTimer.start();
1085     }
1086     }
1087     }else{
1088     (event.currentTarget as VideoDisplay).stop();
1089 mineap 403 (event.currentTarget as VideoDisplay).removeEventListener(MediaPlayerStateChangeEvent.MEDIA_PLAYER_STATE_CHANGE, mediaPlayerStateChanged);
1090 mineap 370 destructor();
1091     }
1092     }
1093    
1094     /**
1095     *
1096     * @param event
1097     *
1098     */
1099     private function convertCompleteHandler(event:Event):void{
1100    
1101     isSwfConverting = false;
1102    
1103     if(loader != null && !isPlayerClosing){
1104    
1105     mc = LoaderInfo(event.currentTarget).loader.content as MovieClip;
1106     swfFrameRate = LoaderInfo(event.currentTarget).loader.contentLoaderInfo.frameRate;
1107     setVolume(videoPlayer.videoController.slider_volume.value);
1108    
1109     if(videoInfoView.isResizePlayerEachPlay){
1110     resizePlayerJustVideoSize(videoPlayer.nowRatio);
1111     }else{
1112     resizePlayerJustVideoSize();
1113     }
1114    
1115     videoPlayer.label_downloadStatus.text = "";
1116    
1117     commentTimer.start();
1118     time = (new Date).time;
1119    
1120     }else{
1121    
1122     if(mc != null){
1123     mc.stop();
1124     }
1125     destructor();
1126     if(event.currentTarget as LoaderInfo){
1127     LoaderInfo(event.currentTarget).loader.unloadAndStop(true);
1128     }
1129    
1130     }
1131    
1132     LoaderInfo(event.currentTarget).loader.removeEventListener(Event.COMPLETE, convertCompleteHandler);
1133    
1134     }
1135    
1136     /**
1137     * ���������������������������������������������������������������������
1138     *
1139     * @param videoPath
1140     * @param windowType
1141     * @param comments
1142     * @param ngList
1143     * @param playList ���������������������m3u���������
1144     * @param videoNameList ���������������������������������URL���������������������������������������������������������������������������������
1145     * @param playingIndex ������������������������������
1146     * @param autoPlay ������������
1147     * @param isStreamingPlay ���������������������������������������
1148     * @param downLoadedURL ���������������������URL
1149     * @return
1150     *
1151     */
1152     private function initWithPlayList(videoPath:String, windowType:int, comments:Comments, playList:Array, videoNameList:Array, playListName:String, playingIndex:int,
1153     autoPlay:Boolean = false, isStreamingPlay:Boolean = false, downLoadedURL:String = null, videoTitle:String = null):void{
1154    
1155     // this.streamingRetryCount = 0;
1156    
1157     this.playingIndex = playingIndex;
1158     this.isPlayListingPlay = true;
1159     var videoNameArray:Array = videoNameList;
1160     if(videoNameArray == null){
1161     videoNameArray = new Array();
1162     for(var i:int; i<playList.length; i++){
1163     var url:String = playList[i];
1164     videoNameArray.push(url.substring(url.lastIndexOf("/") + 1));
1165     }
1166     }
1167    
1168     if(downLoadedURL == null){
1169     downLoadedURL = videoPath;
1170     }
1171    
1172     this.videoInfoView.resetPlayList();
1173     this.videoInfoView.setPlayList(playList, videoNameArray, playListName);
1174    
1175     trace("\t"+playList);
1176    
1177     this.init(videoPath, windowType, comments, PathMaker.createThmbInfoPathByVideoPath(downLoadedURL), autoPlay, isStreamingPlay, videoTitle, true, LibraryUtil.getVideoKey(videoTitle));
1178     }
1179    
1180     /**
1181     * VideoPlayer������������������������������������������������������������������������������
1182     *
1183     * @param url
1184     * @param index
1185     * @return
1186     *
1187     */
1188     public function initForVideoPlayer(url:String, index:int):void{
1189     playMovie(url, this.videoInfoView.playList, index, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(index)));
1190     }
1191    
1192     /**
1193 mineap 487 *
1194     * @param isSmoothing
1195     *
1196     */
1197     public function setVideoSmoothing(isSmoothing:Boolean):void{
1198    
1199     if(videoDisplay != null && videoDisplay.videoObject != null){
1200     videoDisplay.videoObject.smoothing = isSmoothing;
1201     }
1202    
1203     }
1204    
1205     /**
1206 mineap 498 *
1207     * @param value 0-3 default=2
1208     *
1209     */
1210     public function setPlayerQuality(value:int):void{
1211     if(videoPlayer.stage != null){
1212    
1213     var qualityStr:String = StageQuality.HIGH;
1214     switch(value){
1215     case 0:
1216     qualityStr = StageQuality.LOW;
1217     break;
1218     case 1:
1219     qualityStr = StageQuality.MEDIUM;
1220     break;
1221     case 2:
1222     qualityStr = StageQuality.HIGH;
1223     break;
1224     case 3:
1225     qualityStr = StageQuality.BEST;
1226     break;
1227     default:
1228     qualityStr = StageQuality.HIGH;
1229     }
1230    
1231     videoPlayer.stage.quality = qualityStr;
1232     }
1233     }
1234    
1235     /**
1236 mineap 370 * videoDisplay���������������������������������������������������������������������������������������������
1237     * ���������������������������������������������������������������
1238     */
1239     public function resizePlayerJustVideoSize(windowSizeRatio:Number = -1):void{
1240    
1241     try{
1242     var ratio:Number = 1;
1243     if(windowSizeRatio != -1){
1244     ratio = windowSizeRatio;
1245     }
1246    
1247     //������������������������������
1248     var videoWindowHeight:int = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1249     var videoWindowWidth:int = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1250    
1251     //���������������������������������
1252     var nicowariWindowHeight:int = PlayerController.NICO_WARI_HEIGHT * ratio;
1253     var nicowariWindowWidth:int = PlayerController.NICO_WARI_WIDTH * ratio;
1254    
1255     //InfoView���������������������������������������
1256     if(isPlayListingPlay){
1257     if(this.videoInfoView != null){
1258     videoInfoView.showPlayingTitle(playingIndex);
1259     }
1260     }
1261    
1262     //���������������������������������������
1263     if(this.videoPlayer.stage != null && this.videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){
1264     //������������������������������������������ ������������������������������������������������������������
1265     if(this.videoInfoView.isResizePlayerEachPlay || windowSizeRatio != -1){
1266    
1267 mineap 381 if(this.windowType == PlayerController.WINDOW_TYPE_FLV && this.videoDisplay != null && this.videoDisplay.videoObject != null){
1268 mineap 370 //FLV������������
1269    
1270 mineap 487 // ���������������������������
1271    
1272     this.videoDisplay.videoObject.smoothing = videoInfoView.isSmoothing;
1273    
1274 mineap 381 if(this.videoInfoView.selectedResizeType == VideoInfoView.RESIZE_TYPE_NICO && this.videoDisplay.videoObject.videoHeight > 0){
1275 mineap 370
1276     //��������������������������������������������������������������� && ��������������������������������������������������� (���������������������������������������������������������������������������������)
1277     var isWideVideo:Boolean = false;
1278 mineap 381 if(WIDE_MODE_ASPECT_RATIO < Number(this.videoDisplay.videoObject.videoWidth)/Number(this.videoDisplay.videoObject.videoHeight)){
1279 mineap 370 // ���������������16:9���
1280     isWideVideo = true;
1281     trace("enable 16:9 mode");
1282     }
1283    
1284     videoWindowHeight = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1285     if(this.videoInfoView.isEnableWideMode && isWideVideo){
1286     // logManager.addLog("���������(16:9)���������");
1287     videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH_WIDE_MODE * ratio;
1288     //������������������������������������������
1289     this.videoDisplay.setConstraintValue("left", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1290     this.videoDisplay.setConstraintValue("right", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1291    
1292     }else{
1293     // logManager.addLog("������������(4:3)���������");
1294     videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1295     //������������������������������������������
1296     this.videoDisplay.setConstraintValue("left", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1297     this.videoDisplay.setConstraintValue("right", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1298    
1299     }
1300    
1301 mineap 418 if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1302 mineap 370 //init������������������������������������������������������������������������������������������������������������������
1303 mineap 418 videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1304 mineap 370 // resizePlayerJustVideoSize(windowSizeRatio);
1305     }
1306 mineap 418 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1307     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1308     }
1309 mineap 370
1310 mineap 381 }else if(this.videoInfoView.selectedResizeType == VideoInfoView.RESIZE_TYPE_VIDEO && this.videoDisplay.videoObject.videoHeight > 0){
1311 mineap 370
1312     //���������������������������������������������������������������������(videoHeight���0���������������������������������������������������������������������)
1313    
1314 mineap 381 videoWindowHeight = this.videoDisplay.videoObject.videoHeight * ratio;
1315     videoWindowWidth = this.videoDisplay.videoObject.videoWidth * ratio;
1316 mineap 370
1317     this.videoDisplay.setConstraintValue("bottom", 0);
1318     this.videoDisplay.setConstraintValue("left", 0);
1319     this.videoDisplay.setConstraintValue("right", 0);
1320     this.videoDisplay.setConstraintValue("top", 0);
1321    
1322 mineap 418 if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1323 mineap 370 //init������������������������������������������������������������������������������������������������������������������
1324 mineap 418 videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1325 mineap 370 // resizePlayerJustVideoSize(windowSizeRatio);
1326     }
1327 mineap 418 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1328     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1329     }
1330 mineap 370 }else{
1331     //������������������������������������������������
1332     return;
1333     }
1334    
1335     }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1336     //SWF������������
1337    
1338     //SWF���������������������������������������
1339     videoWindowHeight = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1340     videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1341    
1342     }
1343    
1344     //TODO ���������������VideoDisplay���������������������������������������������������������������
1345    
1346     var rate:Number = PlayerController.NICO_WARI_WIDTH / PlayerController.NICO_WARI_HEIGHT;
1347     if(videoPlayer.canvas_nicowari.height < 1 ){
1348     //������������������������������������������������������������������������������������
1349     videoWindowHeight += int(videoWindowWidth / rate);
1350     }
1351    
1352     this.videoPlayer.nativeWindow.height += int(videoWindowHeight - this.videoPlayer.canvas_video_back.height);
1353     this.videoPlayer.nativeWindow.width += int(videoWindowWidth - this.videoPlayer.canvas_video_back.width);
1354    
1355     (this.videoPlayer as Window).validateDisplayList();
1356     (this.videoPlayer as Window).validateNow();
1357    
1358     //������������������������������������������������������������������������������������������������������������������
1359     // var diffH:int = this.videoPlayer.nativeWindow.height - this.videoPlayer.stage.stageHeight;
1360     // var diffW:int = this.videoPlayer.nativeWindow.width - this.videoPlayer.stage.stageWidth;
1361    
1362     }
1363    
1364     }
1365    
1366     }catch(error:Error){ //������������������������������������������������������������������������������������������
1367     trace(error.getStackTrace());
1368     logManager.addLog("������������������������������������������:" + error + ", " + error.getStackTrace());
1369     stop();
1370     destructor();
1371     }
1372     }
1373    
1374    
1375     /**
1376     * ������������������������������������������������������������������
1377     * ���������������������������������������������������������������������������������������������
1378     * @return
1379     *
1380     */
1381     public function play():void
1382     {
1383     try{
1384     videoPlayer.canvas_video_back.setFocus();
1385    
1386     var newComments:Comments = null;
1387     videoPlayer.canvas_video.toolTip = null;
1388     if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
1389     if(videoDisplay != null && videoDisplay.playing){
1390     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1391     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1392     this.commentTimer.stop();
1393     this.commentTimer.reset();
1394     videoDisplay.pause();
1395     pausing = true;
1396     }else{
1397     videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
1398     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
1399     if(pausing){
1400     this.videoPlayer.videoController.slider_timeline.enabled = true;
1401     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1402     this.videoDisplay.play();
1403     this.time = (new Date).time;
1404     this.commentTimer.start();
1405     }else{
1406     this.videoPlayer.videoController.slider_timeline.enabled = true;
1407     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1408     if(!isStreamingPlay){
1409     newComments = new Comments(PathMaker.createNomalCommentPathByVideoPath(source),
1410     PathMaker.createOwnerCommentPathByVideoPath(source), this.videoPlayer.getCommentListProvider(),
1411     this.videoPlayer.videoInfoView.ownerCommentProvider, this.ngListManager,
1412     this.videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
1413     this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable);
1414     init(source, PlayerController.WINDOW_TYPE_FLV, newComments, PathMaker.createThmbInfoPathByVideoPath(source), true, isStreamingPlay, null, this.isPlayListingPlay, this._videoID);
1415     }else{
1416     this.playMovie(source, null, -1, this.downLoadedURL);
1417     }
1418     }
1419     pausing = false;
1420     }
1421     }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1422     if(isMovieClipPlaying){
1423     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1424     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1425     this.commentTimer.stop();
1426     this.commentTimer.reset();
1427     mc.stop();
1428     isMovieClipPlaying = false;
1429     pausing = true;
1430     }else{
1431     videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
1432     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
1433     if(pausing){
1434     this.videoPlayer.videoController.slider_timeline.enabled = true;
1435     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1436     mc.play();
1437     isMovieClipPlaying = true;
1438     this.time = (new Date).time;
1439     this.commentTimer.start();
1440     }else{
1441     this.videoPlayer.canvas_video.removeAllChildren();
1442     this.videoPlayer.videoController.slider_timeline.enabled = true;
1443     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1444     if(!isStreamingPlay){
1445     newComments = new Comments(PathMaker.createNomalCommentPathByVideoPath(source),
1446     PathMaker.createOwnerCommentPathByVideoPath(source), this.videoPlayer.getCommentListProvider(),
1447     this.videoPlayer.videoInfoView.ownerCommentProvider, this.ngListManager,
1448     this.videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
1449     this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable);
1450     init(source, PlayerController.WINDOW_TYPE_SWF, newComments, PathMaker.createThmbInfoPathByVideoPath(source), true, isStreamingPlay, null, this.isPlayListingPlay, this._videoID);
1451     }else{
1452     this.playMovie(source, null, -1, this.downLoadedURL);
1453     }
1454     }
1455     pausing = false;
1456     }
1457     }else{
1458     if(this.videoPlayer != null && this.videoPlayer.title != null){
1459     this.playMovie(this.videoPlayer.title);
1460     }
1461     }
1462    
1463     }catch(error:Error){
1464     trace(error.getStackTrace());
1465     logManager.addLog("���������������������������:" + error + ":" + error.getStackTrace());
1466     }
1467    
1468     }
1469    
1470    
1471     /**
1472     * ������������������������������������������������
1473     * @return
1474     *
1475     */
1476     public function stop():void
1477     {
1478     try{
1479    
1480     pausing = false;
1481    
1482     if(videoInfoView.isShowAlwaysNicowariArea){
1483     videoPlayer.showNicowariArea();
1484     }else{
1485     videoPlayer.hideNicowariArea();
1486     }
1487    
1488     if(videoPlayer != null && videoPlayer.label_downloadStatus != null){
1489     videoPlayer.canvas_video_back.setFocus();
1490     videoPlayer.label_downloadStatus.text = "";
1491     videoPlayer.canvas_video.toolTip = "���������������������������������������������������������������������������������";
1492     }
1493    
1494     if(this.movieEndTimer != null){
1495     this.movieEndTimer.stop();
1496     this.movieEndTimer = null;
1497     }
1498    
1499     if(renewDownloadManager != null){
1500     try{
1501     renewDownloadManager.close();
1502     renewDownloadManager = null;
1503     logManager.addLog("���������������������������������������������������������");
1504     }catch(error:Error){
1505     trace(error);
1506     }
1507     }else{
1508    
1509     this.videoPlayer.videoController.button_play.enabled = true;
1510     this.videoPlayer.videoController_under.button_play.enabled = true;
1511     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1512     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1513    
1514     this.videoPlayer.videoController_under.slider_timeline.value = 0;
1515     this.videoPlayer.videoController.slider_timeline.value = 0;
1516    
1517     this.commentTimerVpos = 0;
1518     this.commentTimer.stop();
1519     this.commentTimer.reset();
1520     this.commentManager.removeAll();
1521    
1522     //���������������������������������������������
1523     this.destructor();
1524    
1525     //������������������������������������������������������
1526     videoPlayer.canvas_nicowari.removeAllChildren();
1527     if(nicowariMC != null){
1528     this.pauseByNicowari(true);
1529     }
1530    
1531     }
1532    
1533     }catch(error:Error){
1534     trace(error.getStackTrace());
1535     logManager.addLog("������������������������������������������:" + error + ":" + error.getStackTrace());
1536     }
1537    
1538     }
1539    
1540    
1541     /**
1542 mineap 427 * ���������������������������������������������������������������������������������
1543     *
1544     */
1545     public function goToTop():void
1546     {
1547     try{
1548    
1549     pausing = false;
1550    
1551     if(videoInfoView.isShowAlwaysNicowariArea){
1552     videoPlayer.showNicowariArea();
1553     }else{
1554     videoPlayer.hideNicowariArea();
1555     }
1556    
1557     if(videoPlayer != null && videoPlayer.label_downloadStatus != null){
1558     videoPlayer.canvas_video_back.setFocus();
1559     videoPlayer.label_downloadStatus.text = "";
1560     videoPlayer.canvas_video.toolTip = "���������������������������������������������������������������������������������";
1561     }
1562    
1563     if(this.movieEndTimer != null){
1564     this.movieEndTimer.stop();
1565     this.movieEndTimer = null;
1566     }
1567    
1568     if(renewDownloadManager != null){
1569     try{
1570     renewDownloadManager.close();
1571     renewDownloadManager = null;
1572     logManager.addLog("���������������������������������������������������������");
1573     }catch(error:Error){
1574     trace(error);
1575     }
1576     }else{
1577    
1578     this.videoPlayer.videoController.button_play.enabled = true;
1579     this.videoPlayer.videoController_under.button_play.enabled = true;
1580     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1581     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1582    
1583     this.videoPlayer.videoController_under.slider_timeline.value = 0;
1584     this.videoPlayer.videoController.slider_timeline.value = 0;
1585    
1586     this.commentTimerVpos = 0;
1587     this.commentTimer.stop();
1588     this.commentTimer.reset();
1589    
1590     var playing:Boolean = false;
1591     if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
1592     if(videoDisplay != null && videoDisplay.playing){
1593     playing = true;
1594     }
1595     }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1596     if(isMovieClipPlaying){
1597     playing = true;
1598     }
1599     }
1600    
1601     if(playing){
1602     this.play();
1603     }
1604     this.seek(0);
1605    
1606    
1607     //������������������������������������������������������
1608     videoPlayer.canvas_nicowari.removeAllChildren();
1609     if(nicowariMC != null){
1610     this.pauseByNicowari(true);
1611     }
1612    
1613     }
1614    
1615     }catch(error:Error){
1616     trace(error.getStackTrace());
1617     logManager.addLog("������������������������������������������:" + error + ":" + error.getStackTrace());
1618     }
1619     }
1620    
1621     /**
1622 mineap 370 * VideoDisplay���������������������������������������������������������
1623     * @param videoDisplay
1624     *
1625     */
1626     private function addVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1627 mineap 381 videoDisplay.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1628     videoDisplay.addEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1629     videoDisplay.addEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1630 mineap 370 }
1631    
1632     /**
1633     * VideoDisplay���������������������������������������������������������
1634     * @param videoDisplay
1635     *
1636     */
1637     private function removeVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1638 mineap 381 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1639     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1640 mineap 370 }
1641 mineap 381 if(videoDisplay.hasEventListener(TimeEvent.DURATION_CHANGE)){
1642     videoDisplay.removeEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1643 mineap 370 }
1644     if(videoDisplay.hasEventListener(VideoEvent.COMPLETE)){
1645 mineap 381 videoDisplay.removeEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1646 mineap 370 }
1647     }
1648    
1649     /**
1650     *
1651 mineap 381 * @param event
1652     *
1653     */
1654     private function durationChangeEventHandler(event:TimeEvent):void{
1655     if(videoInfoView.isResizePlayerEachPlay){
1656     resizePlayerJustVideoSize(videoPlayer.nowRatio);
1657     }else{
1658     resizePlayerJustVideoSize();
1659     }
1660     }
1661    
1662     /**
1663     *
1664 mineap 370 * @param loader
1665     *
1666     */
1667     // private function removeMovieClipEventHandlers(loader:Loader):void{
1668     // if(loader.hasEventListener(Event.COMPLETE)){
1669     // loader.removeEventListener(Event.COMPLETE, convertCompleteHandler);
1670     // }
1671     // }
1672    
1673     /**
1674     * ������������������������������������������������������������������������������
1675     * @return
1676     *
1677     */
1678     public function getStreamingProgress():int{
1679     var value:int = 0;
1680     if(isStreamingPlay){
1681     if(videoDisplay != null){
1682     value = (videoDisplay.bytesLoaded*100 / videoDisplay.bytesTotal);
1683     }else if(loader != null && loader.contentLoaderInfo != null){
1684     value = (loader.contentLoaderInfo.bytesLoaded*100 / loader.contentLoaderInfo.bytesTotal);
1685     }else{
1686     value = 100;
1687     }
1688     }else{
1689     value = 100;
1690     }
1691     return value;
1692     }
1693    
1694     /**
1695     *
1696     * @return
1697     *
1698     */
1699     public function get bytesLoaded():Number{
1700    
1701     var value:Number = 0.0;
1702    
1703     if(videoDisplay != null){
1704     value = videoDisplay.bytesLoaded;
1705     }else if(loader != null && loader.contentLoaderInfo != null){
1706     value = loader.contentLoaderInfo.bytesLoaded;
1707     }
1708    
1709     return value;
1710     }
1711    
1712     /**
1713     *
1714     * @param event
1715     *
1716     */
1717     private function streamingProgressHandler(event:TimerEvent):void{
1718     if(isStreamingPlay){
1719     var value:int = getStreamingProgress();
1720     if(value >= 100){
1721     this.videoPlayer.label_playSourceStatus.text = "Streaming:100%";
1722     streamingProgressCount = 0;
1723     videoPlayer.videoController.resetStatusAlpha();
1724     if(streamingProgressTimer != null){
1725     streamingProgressTimer.stop();
1726     }
1727    
1728     // 100%���������������������������������������������������������������������������������������
1729     if(this.bytesLoaded <= 64){
1730     if(this.streamingRetryCount <= 3 ){
1731     // ���������������
1732     this.streamingRetryCount++;
1733     stop();
1734     logManager.addLog("���������������������������������������(���������������������������:������������������������������:" + this.bytesLoaded + ")");
1735     videoPlayer.label_downloadStatus.text = "������������������������������������������������������������������(" + this.streamingRetryCount +"������ )";
1736    
1737     if(nicoVideoAccessRetryTimer != null){
1738     nicoVideoAccessRetryTimer.stop();
1739     nicoVideoAccessRetryTimer = null;
1740     }
1741 mineap 440 nicoVideoAccessRetryTimer = new Timer(5000*this.streamingRetryCount, 1);
1742 mineap 370 nicoVideoAccessRetryTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
1743     (event.currentTarget as Timer).stop();
1744     play();
1745     });
1746     nicoVideoAccessRetryTimer.start();
1747    
1748     }else{
1749     stop();
1750     logManager.addLog("���������������������������:������������������������������:" + this.bytesLoaded);
1751     videoPlayer.label_downloadStatus.text = "���������������������������������������������(���������������������������������������������������)";
1752     }
1753     }else{
1754     // ������������������
1755     this.streamingRetryCount = 0;
1756     }
1757    
1758     }else{
1759    
1760     var str:String = " ";
1761     if(streamingProgressCount <= 10){
1762     str = ". ";
1763     }else if(streamingProgressCount > 10 && streamingProgressCount <= 20){
1764     str = ".. ";
1765     }else if(streamingProgressCount > 20 && streamingProgressCount <= 30){
1766     str = "...";
1767     }
1768    
1769     this.videoPlayer.label_playSourceStatus.text = "Streaming:" + value + "%" + str;
1770     if(streamingProgressCount >= 30){
1771     streamingProgressCount = 0;
1772     }else{
1773     streamingProgressCount = streamingProgressCount + 2;
1774     }
1775     }
1776     }else{
1777     if(streamingProgressTimer != null){
1778     streamingProgressTimer.stop();
1779     }
1780     }
1781     }
1782    
1783     /**
1784     * ������������������������������������������������������
1785     * @param evt
1786     *
1787     */
1788 mineap 381 private function currentTimeChangeEventHandler(event:TimeEvent = null):void{
1789 mineap 370 try{
1790     var allSec:String="00",allMin:String="0";
1791     var nowSec:String="00",nowMin:String="0";
1792    
1793 mineap 381 this.commentTimerVpos = event.time*1000;
1794 mineap 370
1795 mineap 381 nowSec = String(int(this.videoDisplay.currentTime%60));
1796     nowMin = String(int(this.videoDisplay.currentTime/60));
1797 mineap 370
1798 mineap 381 allSec = String(int(this.videoDisplay.duration%60));
1799     allMin = String(int(this.videoDisplay.duration/60));
1800 mineap 370
1801     if(nowSec.length == 1){
1802     nowSec = "0" + nowSec;
1803     }
1804     if(allSec.length == 1){
1805     allSec = "0" + allSec;
1806     }
1807    
1808     videoPlayer.videoController_under.slider_timeline.enabled = true;
1809     videoPlayer.videoController_under.slider_timeline.minimum = 0;
1810 mineap 381 videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1811 mineap 370 if(!this.sliderChanging){
1812    
1813 mineap 381 this.videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1814     this.videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1815     videoPlayer.videoController_under.slider_timeline.value = videoDisplay.currentTime;
1816 mineap 370
1817     }
1818     videoPlayer.videoController_under.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1819     videoPlayer.videoController_under.slider_timeline.enabled = true;
1820    
1821     videoPlayer.videoController.slider_timeline.enabled = true;
1822     videoPlayer.videoController.slider_timeline.minimum = 0;
1823 mineap 381 videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1824 mineap 370 if(!this.sliderChanging){
1825 mineap 381 videoPlayer.videoController.slider_timeline.value = videoDisplay.currentTime;
1826 mineap 370 }
1827     videoPlayer.videoController.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1828     videoPlayer.videoController.slider_timeline.enabled = true;
1829     }catch(error:Error){
1830 mineap 381 VideoDisplay(event.currentTarget).stop();
1831 mineap 370 trace(error.getStackTrace());
1832     }
1833     }
1834    
1835     /**
1836     * ������������������������������������������������������������������������
1837     * @param evt
1838     *
1839     */
1840 mineap 381 private function videoDisplayCompleteHandler(evt:TimeEvent = null):void{
1841 mineap 370
1842     if(movieEndTimer != null){
1843     movieEndTimer.stop();
1844     movieEndTimer = null;
1845     }
1846     //���������������������������������������������������������
1847     movieEndTimer = new Timer(2000, 1);
1848     movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, videoPlayCompleteWaitHandler);
1849     movieEndTimer.start();
1850    
1851     }
1852    
1853     /**
1854     *
1855     *
1856     */
1857     private function videoPlayCompleteWaitHandler(event:TimerEvent):void{
1858     if(!isCounted){
1859     //���������������������
1860     var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
1861     if(videoId != null){
1862     addVideoPlayCount(videoId, true);
1863     }
1864     isCounted = true;
1865     }
1866    
1867     logManager.addLog("***���������������***");
1868    
1869     if(videoPlayer.isRepeat){
1870     if(isPlayListingPlay){
1871     if(isStreamingPlay){
1872     logManager.addLog("***���������������������(���������������������)***");
1873     this.seek(0);
1874     if(this.videoDisplay != null){
1875     this.videoDisplay.play();
1876     }
1877     }else{
1878     logManager.addLog("***���������������������(������������)***");
1879     this.stop();
1880     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList, playingIndex, this.videoPlayer.title);
1881    
1882     }
1883     }else if(isStreamingPlay){
1884     logManager.addLog("***���������������������(���������������������)***");
1885     this.seek(0);
1886     if(this.videoDisplay != null){
1887     this.videoDisplay.play();
1888     }
1889     }else{
1890     logManager.addLog("***���������������������(������������)***");
1891     this.stop();
1892     this.play();
1893     }
1894     }else{
1895     this.stop();
1896     if(isPlayListingPlay){
1897     logManager.addLog("***���������������(������������)***");
1898     var windowType:int = PlayerController.WINDOW_TYPE_FLV;
1899     if(playingIndex >= this.videoInfoView.getPlayList().length-1){
1900     playingIndex = 0;
1901     if(this.videoPlayer.videoInfoView.isRepeatAll()){
1902     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1903     playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1904     }
1905     }else{
1906     playingIndex++;
1907     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1908     playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1909     }
1910     }
1911     }
1912     }
1913    
1914    
1915     /**
1916     * SWF������������������������������������������������������������������
1917     *
1918     */
1919     private function movieClipCompleteHandler():void{
1920    
1921     this.lastFrame = 0;
1922     this.lastNicowariFrame = 0;
1923    
1924     if(movieEndTimer != null){
1925     movieEndTimer.stop();
1926     movieEndTimer = null;
1927     }
1928     //���������������������������������������������������������
1929     movieEndTimer = new Timer(2000, 1);
1930     movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, movieClipPlayCompleteWaitHandler);
1931     movieEndTimer.start();
1932    
1933    
1934     }
1935    
1936     /**
1937     *
1938     *
1939     */
1940     private function movieClipPlayCompleteWaitHandler(event:TimerEvent):void{
1941     if(!isCounted){
1942     //���������������������
1943     var videoId:String = LibraryUtil.getVideoKey(this.source);
1944     if(videoId == null){
1945     //���������������������������������������������������������
1946     videoId = LibraryUtil.getVideoKey(this.videoPlayer.title);
1947     }
1948     if(videoId != null){
1949     addVideoPlayCount(videoId, true);
1950     }
1951     isCounted = true;
1952     }
1953    
1954     logManager.addLog("***���������������***");
1955     this.lastFrame = 0;
1956     this.lastNicowariFrame = 0;
1957    
1958     if(videoPlayer.isRepeat){
1959     if(isPlayListingPlay){
1960     if(isStreamingPlay){
1961     logManager.addLog("***���������������������(���������������������)***");
1962     this.seek(0);
1963     }else{
1964     logManager.addLog("***���������������������(������������)***");
1965     this.stop();
1966     mc.gotoAndStop(0);
1967     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1968     playingIndex, this.videoPlayer.title);
1969     }
1970     }else if(isStreamingPlay){
1971     logManager.addLog("***���������������������(���������������������)***");
1972     this.seek(0);
1973     }else{
1974     logManager.addLog("***���������������������(������������)***");
1975     this.stop();
1976     mc.gotoAndStop(0);
1977     this.play();
1978     }
1979     }else{
1980     this.stop();
1981     mc.gotoAndStop(0);
1982     if(isPlayListingPlay){
1983     logManager.addLog("***���������������(������������)***");
1984     var windowType:int = PlayerController.WINDOW_TYPE_FLV;
1985     if(playingIndex >= this.videoInfoView.getPlayList().length-1){
1986     playingIndex = 0;
1987     if(this.videoPlayer.videoInfoView.isRepeatAll()){
1988     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1989     playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1990     }
1991     }else{
1992     playingIndex++;
1993     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1994     playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1995     }
1996     }
1997     }
1998    
1999     isMovieClipStopping = false;
2000     }
2001    
2002    
2003     /**
2004     * ���������������������ID������������������������������������������������������������1���������������
2005     * @param videoId ���������������������������������������������������ID
2006     * @param isSave ���������������������������������������������������
2007     */
2008     private function addVideoPlayCount(videoId:String, isSave:Boolean):void{
2009     var nnddVideo:NNDDVideo = libraryManager.isExist(videoId);
2010     if(nnddVideo != null){
2011     nnddVideo.playCount = nnddVideo.playCount + 1;
2012     libraryManager.update(nnddVideo, isSave);
2013     trace("���������������������:" + nnddVideo.videoName + "," + nnddVideo.playCount);
2014     }else{
2015     //���������������
2016     trace("������������������������������������:" + videoId);
2017     }
2018     }
2019    
2020     /**
2021     * ���������������������������������������������
2022     * swf���������������SWF���������������������������������������������������
2023     *
2024     * @param event
2025     *
2026     */
2027     private function commentTimerHandler(event:TimerEvent):void{
2028    
2029     if(isPlayerClosing){
2030     if(commentTimer != null){
2031     commentTimer.stop();
2032     commentTimer.reset();
2033     }
2034     return;
2035     }
2036    
2037     // ���������������
2038     this.setVolume(this.videoPlayer.videoController.slider_volume.value);
2039    
2040     var nowSec:String="00",nowMin:String="0";
2041     nowSec = String(int(commentTimerVpos/1000%60));
2042     nowMin = String(int(commentTimerVpos/1000/60));
2043     if(nowSec.length == 1){
2044     nowSec = "0" + nowSec;
2045     }
2046     var nowTime:String = nowMin + ":" + nowSec;
2047    
2048     var allSec:String="00",allMin:String="0"
2049     if(this.windowType==PlayerController.WINDOW_TYPE_SWF && this.mc != null){
2050     allSec = String(int(mc.totalFrames/swfFrameRate%60));
2051     allMin = String(int(mc.totalFrames/swfFrameRate/60));
2052     }else if(this.windowType==PlayerController.WINDOW_TYPE_FLV && this.videoDisplay != null){
2053 mineap 381 allSec = String(int(videoDisplay.duration%60));
2054     allMin = String(int(videoDisplay.duration/60));
2055 mineap 370 }
2056     if(allSec.length == 1){
2057     allSec = "0" + allSec;
2058     }
2059     var allTime:String = allMin +":" + allSec;
2060    
2061     if(!isCounted && commentTimerVpos > 10000){
2062     //���������������������
2063     var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
2064     if(videoId != null){
2065     addVideoPlayCount(videoId, false);
2066     }
2067     isCounted = true;
2068     }
2069    
2070     //SWF���������������������������������������������������������������������
2071     if(isMovieClipPlaying && this.windowType==PlayerController.WINDOW_TYPE_SWF && this.mc != null){
2072    
2073     videoPlayer.videoController_under.slider_timeline.enabled = true;
2074     videoPlayer.videoController_under.slider_timeline.minimum = 0;
2075     videoPlayer.videoController_under.slider_timeline.maximum = mc.totalFrames;
2076    
2077     videoPlayer.videoController.slider_timeline.enabled = true;
2078     videoPlayer.videoController.slider_timeline.minimum = 0;
2079     videoPlayer.videoController.slider_timeline.maximum = mc.totalFrames;
2080    
2081     if(!this.sliderChanging){
2082     videoPlayer.videoController_under.slider_timeline.value = mc.currentFrame;
2083     videoPlayer.videoController.slider_timeline.value = mc.currentFrame;
2084     }
2085    
2086     // trace(nowMin + "/" + nowSec);
2087    
2088     videoPlayer.videoController_under.label_time.text = nowTime + "/"+ allTime;
2089     videoPlayer.videoController.label_time.text = nowTime + "/"+ allTime;
2090    
2091     if(mc.currentFrame >= mc.totalFrames-1 || mc.currentFrame == this.lastFrame ){
2092     this.lastFrame = mc.currentFrame;
2093     //���������movieClip������������������������������������������������������
2094     if(!isMovieClipStopping){
2095     isMovieClipStopping = true;
2096     movieClipCompleteHandler();
2097     }
2098     return;
2099     }else{
2100     if(!isMovieClipStopping){
2101     this.lastFrame = mc.currentFrame;
2102     }
2103     }
2104     }
2105    
2106     var tempTime:Number = (new Date).time;
2107    
2108     //SWF������������������������������������������������������������������
2109     if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
2110     this.commentTimerVpos += (tempTime - this.time);
2111     }
2112    
2113     //���������������������
2114     var commentArray:Vector.<NNDDComment> = this.commentManager.setComment(commentTimerVpos, (tempTime - this.time)*3, this.videoPlayer.isShowComment);
2115     this.commentManager.moveComment(tempTime/1000 - this.time/1000, videoInfoView.showCommentSec);
2116     this.commentManager.removeComment(commentTimerVpos, videoInfoView.showCommentSec * 1000);
2117     this.time = tempTime;
2118    
2119     //������������������������������������������������������
2120     if(videoPlayer.videoInfoView.checkbox_SyncComment.selected && videoPlayer.videoInfoView.visible
2121     // && (videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE
2122     // && videoInfoView.isActive)
2123     ){
2124    
2125     var lastMin:String = commentManager.getComments().lastMin;
2126    
2127     var tempNowTime:String = nowTime;
2128     if(lastMin.length == 3){
2129     //���������������3���������������:���������������������
2130     if(tempNowTime.length == 4){
2131     //���������������:������������4���
2132     tempNowTime = "00" + tempNowTime;
2133     }else if(tempNowTime.length == 5){
2134     //���������������:������������5���
2135     tempNowTime = "0" + tempNowTime;
2136     }
2137     }else if(lastMin.length == 2){
2138     //���������������2���������������:������������5������
2139     if(tempNowTime.length == 4){
2140     //���������������:������������4���
2141     tempNowTime = "0" + tempNowTime;
2142     }
2143    
2144     }else if(lastMin.length == 1){
2145     //���������������1���������������:������������4������
2146    
2147     }
2148    
2149     if(tempNowTime.length > lastMin.length+3){
2150     tempNowTime = tempNowTime.substring(1);
2151     }
2152    
2153    
2154     var index:int = 0;
2155     if(commentArray.length > 0 && comments != null){
2156     var myComment:NNDDComment = commentArray[0];
2157     for each(var comment:NNDDComment in commentArray){
2158     if(comment.vpos > myComment.vpos){
2159     myComment = comment;
2160     }
2161     }
2162     index = comments.getCommentIndex(tempNowTime, myComment.text);
2163    
2164     if(this.videoPlayer.videoInfoView.tabNavigator_comment.selectedIndex == 0){
2165    
2166     if(this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition < index){
2167     index = index - (this.videoPlayer.videoInfoView.dataGrid_comment.rowCount) + 2;
2168     if(index > 0){
2169     if(index < this.videoPlayer.videoInfoView.dataGrid_comment.maxVerticalScrollPosition){
2170     this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = index;
2171     }else{
2172     this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = this.videoPlayer.videoInfoView.dataGrid_comment.maxVerticalScrollPosition;
2173     }
2174     }
2175     }
2176    
2177     }else if(this.videoPlayer.videoInfoView.tabNavigator_comment.selectedIndex == 1){
2178    
2179     if(this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition < index){
2180     index = index - (this.videoPlayer.videoInfoView.dataGrid_oldComment.rowCount) + 2;
2181     if(index > 0){
2182     if(index < this.videoPlayer.videoInfoView.dataGrid_oldComment.maxVerticalScrollPosition){
2183     this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition = index;
2184     }else{
2185     this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition = this.videoPlayer.videoInfoView.dataGrid_oldComment.maxVerticalScrollPosition;
2186     }
2187     }
2188     }
2189    
2190     }
2191    
2192     }
2193     }
2194    
2195    
2196     //������������������������
2197     var date:Date = new Date();
2198     var hh:String = new String(int(date.getHours()));
2199     var mm:String = new String(int(date.getMinutes()));
2200     if(hh.length == 1){
2201     hh = "0" + hh;
2202     }
2203     if(mm.length == 1){
2204     mm = "0" + mm;
2205     }
2206     var jihouResult:Array = commentManager.isJihouSettingTime(hh + mm);
2207     if(jihouResult != null && playingJihou == null){
2208     //������������
2209     playingJihou = hh+mm;
2210     playNicowari(jihouResult[0], jihouResult[1]);
2211     }
2212     if(playingJihou != null && playingJihou != (hh+mm)){
2213     playingJihou = null;
2214     }
2215    
2216     if(!this.videoPlayer.isShowComment){
2217     this.commentManager.removeAll();
2218     }
2219    
2220     }
2221    
2222     /**
2223     * ������������������������������������������������������������������������
2224     * @param volume 0������1���������������������������������������������
2225     * @return ������������������������������������
2226     *
2227     */
2228     public