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