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