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