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 808 - (hide annotations) (download)
Wed May 2 05:31:56 2012 UTC (11 years, 11 months ago) by mineap
File size: 167586 byte(s)
NicoSound対応
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 mineap 807 // trace(videoPlayer.stage.quality);
565 mineap 512
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 mineap 807 this.videoDisplay.setConstraintValue("bottom", 0);
1381     this.videoDisplay.setConstraintValue("left", NICO_VIDEO_PADDING);
1382     this.videoDisplay.setConstraintValue("right", NICO_VIDEO_PADDING);
1383     this.videoDisplay.setConstraintValue("top", 0);
1384 mineap 529
1385     trace(videoDisplay.width + "," + videoDisplay.height);
1386    
1387 mineap 681 logManager.addLog("���������������������������������:" + this.videoDisplay.videoObject.videoWidth + " x " + this.videoDisplay.videoObject.videoHeight);
1388    
1389 mineap 418 if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1390 mineap 370 //init������������������������������������������������������������������������������������������������������������������
1391 mineap 418 videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1392 mineap 370 // resizePlayerJustVideoSize(windowSizeRatio);
1393     }
1394 mineap 418 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1395     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1396     }
1397 mineap 370
1398 mineap 381 }else if(this.videoInfoView.selectedResizeType == VideoInfoView.RESIZE_TYPE_VIDEO && this.videoDisplay.videoObject.videoHeight > 0){
1399 mineap 370
1400     //���������������������������������������������������������������������(videoHeight���0���������������������������������������������������������������������)
1401    
1402 mineap 807 videoWindowHeight = (this.videoDisplay.videoObject.videoHeight * ratio) + PlayerController.NICO_VIDEO_PADDING*2;
1403     videoWindowWidth = (this.videoDisplay.videoObject.videoWidth * ratio) + PlayerController.NICO_VIDEO_PADDING*2;
1404 mineap 370
1405 mineap 807 this.videoDisplay.setConstraintValue("bottom", NICO_VIDEO_PADDING);
1406     this.videoDisplay.setConstraintValue("left", NICO_VIDEO_PADDING);
1407     this.videoDisplay.setConstraintValue("right", NICO_VIDEO_PADDING);
1408     this.videoDisplay.setConstraintValue("top", NICO_VIDEO_PADDING);
1409 mineap 370
1410 mineap 418 if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1411 mineap 370 //init������������������������������������������������������������������������������������������������������������������
1412 mineap 418 videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1413 mineap 370 // resizePlayerJustVideoSize(windowSizeRatio);
1414     }
1415 mineap 418 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1416     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1417     }
1418 mineap 370 }else{
1419     //������������������������������������������������
1420     return;
1421     }
1422    
1423     }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1424     //SWF������������
1425    
1426     //SWF���������������������������������������
1427 mineap 799 if (_useOldVersionVideoSize)
1428     {
1429     videoWindowHeight = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1430     videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1431     }
1432     else
1433     {
1434     videoWindowHeight = PlayerController.NICO_VIDEO_NEW_WINDOW_HEIGHT * ratio;
1435     videoWindowWidth = PlayerController.NICO_VIDEO_NEW_WINDOW_WIDTH * ratio;
1436     }
1437 mineap 370
1438     }
1439    
1440     if(videoPlayer.canvas_nicowari.height < 1 ){
1441     //������������������������������������������������������������������������������������
1442 mineap 807 videoWindowHeight += (NICO_WARI_HEIGHT + NICO_VIDEO_PADDING);
1443     }else
1444     {
1445     videoWindowHeight += NICO_VIDEO_PADDING;
1446 mineap 370 }
1447    
1448     this.videoPlayer.nativeWindow.height += int(videoWindowHeight - this.videoPlayer.canvas_video_back.height);
1449     this.videoPlayer.nativeWindow.width += int(videoWindowWidth - this.videoPlayer.canvas_video_back.width);
1450    
1451 mineap 681 if (this.videoDisplay != null)
1452     {
1453     logManager.addLog("���������������������������:" + this.videoDisplay.width + " x " + this.videoDisplay.height);
1454     }
1455    
1456 mineap 544 // (this.videoPlayer as Window).validateDisplayList();
1457     // (this.videoPlayer as Window).validateNow();
1458 mineap 370
1459     //������������������������������������������������������������������������������������������������������������������
1460     // var diffH:int = this.videoPlayer.nativeWindow.height - this.videoPlayer.stage.stageHeight;
1461     // var diffW:int = this.videoPlayer.nativeWindow.width - this.videoPlayer.stage.stageWidth;
1462    
1463     }
1464 mineap 525 else
1465     {
1466     // ������������������������������������������
1467     if(this.windowType == PlayerController.WINDOW_TYPE_FLV && this.videoDisplay != null && this.videoDisplay.videoObject != null){
1468     //FLV������������
1469    
1470     // ���������������������������
1471 mineap 529 this.setVideoSmoothing(videoInfoView.isSmoothing);
1472 mineap 525
1473     if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1474     //init������������������������������������������������������������������������������������������������������������������
1475     videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1476     }
1477     if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1478     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1479     }
1480    
1481     }
1482    
1483     }
1484 mineap 370
1485     }
1486 mineap 569 else
1487     {
1488     if (PlayerController.WINDOW_TYPE_FLV == this.windowType)
1489     {
1490     if (videoInfoView != null)
1491     {
1492     this.setVideoSmoothing(videoInfoView.isSmoothing);
1493     }
1494     }
1495     }
1496 mineap 807
1497     updateVideoStatus();
1498 mineap 370
1499     }catch(error:Error){ //������������������������������������������������������������������������������������������
1500     trace(error.getStackTrace());
1501     logManager.addLog("������������������������������������������:" + error + ", " + error.getStackTrace());
1502     stop();
1503     destructor();
1504     }
1505     }
1506    
1507    
1508     /**
1509     * ������������������������������������������������������������������
1510     * ���������������������������������������������������������������������������������������������
1511     * @return
1512     *
1513     */
1514     public function play():void
1515     {
1516     try{
1517     videoPlayer.canvas_video_back.setFocus();
1518    
1519     var newComments:Comments = null;
1520     videoPlayer.canvas_video.toolTip = null;
1521     if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
1522     if(videoDisplay != null && videoDisplay.playing){
1523     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1524     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1525     this.commentTimer.stop();
1526     this.commentTimer.reset();
1527     videoDisplay.pause();
1528     pausing = true;
1529     }else{
1530     videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
1531     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
1532     if(pausing){
1533     this.videoPlayer.videoController.slider_timeline.enabled = true;
1534     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1535     this.videoDisplay.play();
1536     this.time = (new Date).time;
1537     this.commentTimer.start();
1538     }else{
1539     this.videoPlayer.videoController.slider_timeline.enabled = true;
1540     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1541 mineap 507 this.playMovie(source, null, -1, this.downLoadedURL);
1542 mineap 370 }
1543     pausing = false;
1544     }
1545     }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1546     if(isMovieClipPlaying){
1547     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1548     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1549     this.commentTimer.stop();
1550     this.commentTimer.reset();
1551     mc.stop();
1552     isMovieClipPlaying = false;
1553     pausing = true;
1554     }else{
1555     videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
1556     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
1557     if(pausing){
1558     this.videoPlayer.videoController.slider_timeline.enabled = true;
1559     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1560     mc.play();
1561     isMovieClipPlaying = true;
1562     this.time = (new Date).time;
1563     this.commentTimer.start();
1564     }else{
1565     this.videoPlayer.canvas_video.removeAllChildren();
1566     this.videoPlayer.videoController.slider_timeline.enabled = true;
1567     this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1568 mineap 507 this.playMovie(source, null, -1, this.downLoadedURL);
1569    
1570 mineap 370 }
1571     pausing = false;
1572     }
1573     }else{
1574     if(this.videoPlayer != null && this.videoPlayer.title != null){
1575     this.playMovie(this.videoPlayer.title);
1576     }
1577     }
1578    
1579     }catch(error:Error){
1580     trace(error.getStackTrace());
1581     logManager.addLog("���������������������������:" + error + ":" + error.getStackTrace());
1582     }
1583    
1584     }
1585    
1586    
1587     /**
1588     * ������������������������������������������������
1589     * @return
1590     *
1591     */
1592     public function stop():void
1593     {
1594     try{
1595    
1596     pausing = false;
1597    
1598     if(videoInfoView.isShowAlwaysNicowariArea){
1599     videoPlayer.showNicowariArea();
1600     }else{
1601     videoPlayer.hideNicowariArea();
1602     }
1603    
1604     if(videoPlayer != null && videoPlayer.label_downloadStatus != null){
1605     videoPlayer.canvas_video_back.setFocus();
1606     videoPlayer.label_downloadStatus.text = "";
1607     videoPlayer.canvas_video.toolTip = "���������������������������������������������������������������������������������";
1608     }
1609    
1610     if(this.movieEndTimer != null){
1611     this.movieEndTimer.stop();
1612     this.movieEndTimer = null;
1613     }
1614    
1615     if(renewDownloadManager != null){
1616     try{
1617     renewDownloadManager.close();
1618     renewDownloadManager = null;
1619     logManager.addLog("���������������������������������������������������������");
1620     }catch(error:Error){
1621     trace(error);
1622     }
1623     }else{
1624    
1625     this.videoPlayer.videoController.button_play.enabled = true;
1626     this.videoPlayer.videoController_under.button_play.enabled = true;
1627     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1628     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1629    
1630     this.videoPlayer.videoController_under.slider_timeline.value = 0;
1631     this.videoPlayer.videoController.slider_timeline.value = 0;
1632    
1633     this.commentTimerVpos = 0;
1634     this.commentTimer.stop();
1635     this.commentTimer.reset();
1636     this.commentManager.removeAll();
1637    
1638     //���������������������������������������������
1639     this.destructor();
1640    
1641     //������������������������������������������������������
1642     videoPlayer.canvas_nicowari.removeAllChildren();
1643     if(nicowariMC != null){
1644     this.pauseByNicowari(true);
1645     }
1646    
1647     }
1648    
1649     }catch(error:Error){
1650     trace(error.getStackTrace());
1651     logManager.addLog("������������������������������������������:" + error + ":" + error.getStackTrace());
1652     }
1653    
1654     }
1655    
1656    
1657     /**
1658 mineap 427 * ���������������������������������������������������������������������������������
1659     *
1660     */
1661     public function goToTop():void
1662     {
1663     try{
1664    
1665     pausing = false;
1666    
1667     if(videoInfoView.isShowAlwaysNicowariArea){
1668     videoPlayer.showNicowariArea();
1669     }else{
1670     videoPlayer.hideNicowariArea();
1671     }
1672    
1673     if(videoPlayer != null && videoPlayer.label_downloadStatus != null){
1674     videoPlayer.canvas_video_back.setFocus();
1675     videoPlayer.label_downloadStatus.text = "";
1676     videoPlayer.canvas_video.toolTip = "���������������������������������������������������������������������������������";
1677     }
1678    
1679     if(this.movieEndTimer != null){
1680     this.movieEndTimer.stop();
1681     this.movieEndTimer = null;
1682     }
1683    
1684     if(renewDownloadManager != null){
1685     try{
1686     renewDownloadManager.close();
1687     renewDownloadManager = null;
1688     logManager.addLog("���������������������������������������������������������");
1689     }catch(error:Error){
1690     trace(error);
1691     }
1692     }else{
1693    
1694     this.videoPlayer.videoController.button_play.enabled = true;
1695     this.videoPlayer.videoController_under.button_play.enabled = true;
1696     videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1697     videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1698    
1699     this.videoPlayer.videoController_under.slider_timeline.value = 0;
1700     this.videoPlayer.videoController.slider_timeline.value = 0;
1701    
1702     this.commentTimerVpos = 0;
1703     this.commentTimer.stop();
1704     this.commentTimer.reset();
1705    
1706     var playing:Boolean = false;
1707     if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
1708     if(videoDisplay != null && videoDisplay.playing){
1709     playing = true;
1710     }
1711     }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1712     if(isMovieClipPlaying){
1713     playing = true;
1714     }
1715     }
1716    
1717     if(playing){
1718     this.play();
1719     }
1720     this.seek(0);
1721    
1722    
1723     //������������������������������������������������������
1724     videoPlayer.canvas_nicowari.removeAllChildren();
1725     if(nicowariMC != null){
1726     this.pauseByNicowari(true);
1727     }
1728    
1729     }
1730    
1731     }catch(error:Error){
1732     trace(error.getStackTrace());
1733     logManager.addLog("������������������������������������������:" + error + ":" + error.getStackTrace());
1734     }
1735     }
1736    
1737     /**
1738 mineap 370 * VideoDisplay���������������������������������������������������������
1739     * @param videoDisplay
1740     *
1741     */
1742     private function addVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1743 mineap 381 videoDisplay.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1744     videoDisplay.addEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1745     videoDisplay.addEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1746 mineap 370 }
1747    
1748     /**
1749     * VideoDisplay���������������������������������������������������������
1750     * @param videoDisplay
1751     *
1752     */
1753     private function removeVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1754 mineap 381 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1755     videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1756 mineap 370 }
1757 mineap 381 if(videoDisplay.hasEventListener(TimeEvent.DURATION_CHANGE)){
1758     videoDisplay.removeEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1759 mineap 370 }
1760     if(videoDisplay.hasEventListener(VideoEvent.COMPLETE)){
1761 mineap 381 videoDisplay.removeEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1762 mineap 370 }
1763     }
1764    
1765     /**
1766     *
1767 mineap 381 * @param event
1768     *
1769     */
1770     private function durationChangeEventHandler(event:TimeEvent):void{
1771     if(videoInfoView.isResizePlayerEachPlay){
1772     resizePlayerJustVideoSize(videoPlayer.nowRatio);
1773     }else{
1774     resizePlayerJustVideoSize();
1775     }
1776     }
1777    
1778     /**
1779     *
1780 mineap 370 * @param loader
1781     *
1782     */
1783     // private function removeMovieClipEventHandlers(loader:Loader):void{
1784     // if(loader.hasEventListener(Event.COMPLETE)){
1785     // loader.removeEventListener(Event.COMPLETE, convertCompleteHandler);
1786     // }
1787     // }
1788    
1789     /**
1790     * ������������������������������������������������������������������������������
1791     * @return
1792     *
1793     */
1794     public function getStreamingProgress():int{
1795     var value:int = 0;
1796     if(isStreamingPlay){
1797     if(videoDisplay != null){
1798     value = (videoDisplay.bytesLoaded*100 / videoDisplay.bytesTotal);
1799     }else if(loader != null && loader.contentLoaderInfo != null){
1800     value = (loader.contentLoaderInfo.bytesLoaded*100 / loader.contentLoaderInfo.bytesTotal);
1801     }else{
1802     value = 100;
1803     }
1804     }else{
1805     value = 100;
1806     }
1807     return value;
1808     }
1809    
1810 mineap 531
1811 mineap 370 /**
1812 mineap 531 * ���������������������������������������������������MB/s������������������
1813     * @return
1814 mineap 370 *
1815 mineap 531 */
1816     public function getStreamingSpeed():Number
1817     {
1818    
1819     // timer������1000ms���������������������
1820    
1821     var value:Number = 0;
1822     if (isStreamingPlay)
1823     {
1824     if(videoDisplay != null){
1825     value = videoDisplay.bytesLoaded - this.lastLoadedBytes;
1826     this.lastLoadedBytes = videoDisplay.bytesLoaded;
1827     }else if(loader != null && loader.contentLoaderInfo != null){
1828     value = loader.contentLoaderInfo.bytesLoaded - this.lastLoadedBytes;
1829     this.lastLoadedBytes = loader.contentLoaderInfo.bytesLoaded;
1830     }else{
1831     return value;
1832     }
1833    
1834     trace(value);
1835    
1836     //MB���������
1837     value = value / 1000000;
1838    
1839     // MB/s���������
1840     value = value / 1;
1841     }
1842     else
1843     {
1844     // ���������������
1845     }
1846    
1847     return value;
1848    
1849     }
1850    
1851     /**
1852     *
1853 mineap 370 * @return
1854     *
1855     */
1856     public function get bytesLoaded():Number{
1857    
1858     var value:Number = 0.0;
1859    
1860     if(videoDisplay != null){
1861     value = videoDisplay.bytesLoaded;
1862     }else if(loader != null && loader.contentLoaderInfo != null){
1863     value = loader.contentLoaderInfo.bytesLoaded;
1864     }
1865    
1866     return value;
1867     }
1868    
1869     /**
1870     *
1871     * @param event
1872     *
1873     */
1874     private function streamingProgressHandler(event:TimerEvent):void{
1875     if(isStreamingPlay){
1876     var value:int = getStreamingProgress();
1877 mineap 531 var speed:Number = getStreamingSpeed();
1878 mineap 370 if(value >= 100){
1879     this.videoPlayer.label_playSourceStatus.text = "Streaming:100%";
1880     videoPlayer.videoController.resetStatusAlpha();
1881     if(streamingProgressTimer != null){
1882     streamingProgressTimer.stop();
1883     }
1884    
1885     // 100%���������������������������������������������������������������������������������������
1886     if(this.bytesLoaded <= 64){
1887 mineap 580
1888     var maxCount:int = 1;
1889     var confValue:String = ConfigManager.getInstance().getItem("streamingRetryMaxCount");
1890     if(confValue == null)
1891     {
1892     ConfigManager.getInstance().removeItem("streamingRetryMaxCount");
1893     ConfigManager.getInstance().setItem("streamingRetryMaxCount", maxCount);
1894     }
1895     else
1896     {
1897     maxCount = int(confValue);
1898     }
1899    
1900     if(this.streamingRetryCount <= maxCount ){
1901 mineap 370 // ���������������
1902     this.streamingRetryCount++;
1903 mineap 573 var timeStr:String = String(int(10000*this.streamingRetryCount / 1000));
1904 mineap 370 stop();
1905     logManager.addLog("���������������������������������������(���������������������������:������������������������������:" + this.bytesLoaded + ")");
1906 mineap 573 videoPlayer.label_downloadStatus.text = "������������������������������������������������������������������(" + timeStr + "���������" + this.streamingRetryCount +"������ )";
1907 mineap 370
1908     if(nicoVideoAccessRetryTimer != null){
1909     nicoVideoAccessRetryTimer.stop();
1910     nicoVideoAccessRetryTimer = null;
1911     }
1912 mineap 573 nicoVideoAccessRetryTimer = new Timer(10000*this.streamingRetryCount, 1);
1913 mineap 370 nicoVideoAccessRetryTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
1914     (event.currentTarget as Timer).stop();
1915     play();
1916     });
1917     nicoVideoAccessRetryTimer.start();
1918    
1919     }else{
1920     stop();
1921     logManager.addLog("���������������������������:������������������������������:" + this.bytesLoaded);
1922     videoPlayer.label_downloadStatus.text = "���������������������������������������������(���������������������������������������������������)";
1923     }
1924     }else{
1925     // ������������������
1926     this.streamingRetryCount = 0;
1927     }
1928    
1929     }else{
1930    
1931 mineap 531 var formatter:NumberFormatter = new NumberFormatter();
1932     formatter.precision = 2;
1933     var str:String = formatter.format(speed) + "MB/s"
1934 mineap 370
1935 mineap 531 this.videoPlayer.label_playSourceStatus.text = "Streaming:" + value + "% (" + str + ")";
1936 mineap 370 }
1937     }else{
1938     if(streamingProgressTimer != null){
1939     streamingProgressTimer.stop();
1940     }
1941     }
1942     }
1943    
1944     /**
1945     * ������������������������������������������������������
1946     * @param evt
1947     *
1948     */
1949 mineap 381 private function currentTimeChangeEventHandler(event:TimeEvent = null):void{
1950 mineap 370 try{
1951     var allSec:String="00",allMin:String="0";
1952     var nowSec:String="00",nowMin:String="0";
1953    
1954 mineap 381 this.commentTimerVpos = event.time*1000;
1955 mineap 370
1956 mineap 381 nowSec = String(int(this.videoDisplay.currentTime%60));
1957     nowMin = String(int(this.videoDisplay.currentTime/60));
1958 mineap 370
1959 mineap 381 allSec = String(int(this.videoDisplay.duration%60));
1960     allMin = String(int(this.videoDisplay.duration/60));
1961 mineap 370
1962     if(nowSec.length == 1){
1963     nowSec = "0" + nowSec;
1964     }
1965     if(allSec.length == 1){
1966     allSec = "0" + allSec;
1967     }
1968    
1969     videoPlayer.videoController_under.slider_timeline.enabled = true;
1970     videoPlayer.videoController_under.slider_timeline.minimum = 0;
1971 mineap 381 videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1972 mineap 370 if(!this.sliderChanging){
1973    
1974 mineap 381 this.videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1975     this.videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1976     videoPlayer.videoController_under.slider_timeline.value = videoDisplay.currentTime;
1977 mineap 370
1978     }
1979     videoPlayer.videoController_under.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1980     videoPlayer.videoController_under.slider_timeline.enabled = true;
1981    
1982     videoPlayer.videoController.slider_timeline.enabled = true;
1983     videoPlayer.videoController.slider_timeline.minimum = 0;
1984 mineap 381 videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1985 mineap 370 if(!this.sliderChanging){
1986 mineap 381 videoPlayer.videoController.slider_timeline.value = videoDisplay.currentTime;
1987 mineap 370 }
1988     videoPlayer.videoController.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1989     videoPlayer.videoController.slider_timeline.enabled = true;
1990     }catch(error:Error){
1991 mineap 381 VideoDisplay(event.currentTarget).stop();
1992 mineap 370 trace(error.getStackTrace());
1993     }
1994     }
1995    
1996     /**
1997     * ������������������������������������������������������������������������
1998     * @param evt
1999     *
2000     */
2001 mineap 381 private function videoDisplayCompleteHandler(evt:TimeEvent = null):void{
2002 mineap 370
2003     if(movieEndTimer != null){
2004     movieEndTimer.stop();
2005     movieEndTimer = null;
2006     }
2007     //���������������������������������������������������������
2008     movieEndTimer = new Timer(2000, 1);
2009     movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, videoPlayCompleteWaitHandler);
2010     movieEndTimer.start();
2011    
2012     }
2013    
2014     /**
2015     *
2016     *
2017     */
2018     private function videoPlayCompleteWaitHandler(event:TimerEvent):void{
2019 mineap 512 if (!isCounted)
2020     {
2021 mineap 370 //���������������������
2022     var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
2023 mineap 512 if (videoId != null)
2024     {
2025 mineap 370 addVideoPlayCount(videoId, true);
2026     }
2027     isCounted = true;
2028     }
2029    
2030     logManager.addLog("***���������������***");
2031    
2032 mineap 512 if (videoPlayer.isRepeat)
2033     {
2034    
2035     /* ���������1��������������� */
2036    
2037     if (isPlayListingPlay)
2038     {
2039     if(isStreamingPlay)
2040     {
2041 mineap 370 logManager.addLog("***���������������������(���������������������)***");
2042     this.seek(0);
2043 mineap 512 if (this.videoDisplay != null)
2044     {
2045 mineap 370 this.videoDisplay.play();
2046     }
2047 mineap 512 }
2048     else
2049     {
2050 mineap 370 logManager.addLog("***���������������������(������������)***");
2051     this.stop();
2052 mineap 751
2053     var url:String = this.videoInfoView.getPlayListUrl(playingIndex);
2054     var video:NNDDVideo = libraryManager.isExistByVideoId(LibraryUtil.getVideoKey(url));
2055     if (video != null)
2056     {
2057     url = video.getDecodeUrl();
2058     }
2059    
2060 mineap 512 playMovie(
2061 mineap 751 url,
2062 mineap 512 this.videoInfoView.playList,
2063     playingIndex,
2064     this.videoPlayer.title);
2065 mineap 370
2066     }
2067 mineap 512 }
2068     else if(isStreamingPlay)
2069     {
2070 mineap 370 logManager.addLog("***���������������������(���������������������)***");
2071     this.seek(0);
2072 mineap 512 if (this.videoDisplay != null)
2073     {
2074 mineap 370 this.videoDisplay.play();
2075     }
2076 mineap 512 }
2077     else
2078     {
2079 mineap 370 logManager.addLog("***���������������������(������������)***");
2080     this.stop();
2081     this.play();
2082     }
2083 mineap 512 }
2084     else
2085     {
2086    
2087     /* ������������������������������ */
2088    
2089 mineap 370 this.stop();
2090 mineap 512
2091     if (isPlayListingPlay)
2092     {
2093    
2094     /* ��������������������������� */
2095    
2096 mineap 370 logManager.addLog("***���������������(������������)***");
2097     var windowType:int = PlayerController.WINDOW_TYPE_FLV;
2098 mineap 512 if (playingIndex >= this.videoInfoView.getPlayList().length-1)
2099     {
2100     /* ������������������������������������ */
2101 mineap 370 playingIndex = 0;
2102 mineap 512 if (this.videoPlayer.videoInfoView.isRepeatAll())
2103     {
2104 mineap 751 var url:String = this.videoInfoView.getPlayListUrl(playingIndex);
2105     var video:NNDDVideo = libraryManager.isExistByVideoId(LibraryUtil.getVideoKey(url));
2106     if (video != null)
2107     {
2108     url = video.getDecodeUrl();
2109     }
2110    
2111 mineap 512 playMovie(
2112 mineap 751 url,
2113 mineap 512 this.videoInfoView.playList,
2114     playingIndex,
2115     PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
2116 mineap 370 }
2117 mineap 512 }
2118     else
2119     {
2120     /* ������������������������������������ */
2121 mineap 370 playingIndex++;
2122 mineap 751
2123     var url:String = this.videoInfoView.getPlayListUrl(playingIndex);
2124     var video:NNDDVideo = libraryManager.isExistByVideoId(LibraryUtil.getVideoKey(url));
2125     if (video != null)
2126     {
2127     url = video.getDecodeUrl();
2128     }
2129    
2130 mineap 512 playMovie(
2131 mineap 751 url,
2132 mineap 512 this.videoInfoView.playList,
2133     playingIndex,
2134     PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
2135 mineap 370 }
2136     }
2137     }
2138     }
2139    
2140    
2141     /**
2142     * SWF������������������������������������������������������������������
2143     *
2144     */
2145     private function movieClipCompleteHandler():void{
2146    
2147     this.lastFrame = 0;
2148     this.lastNicowariFrame = 0;
2149    
2150     if(movieEndTimer != null){
2151     movieEndTimer.stop();
2152     movieEndTimer = null;
2153     }
2154     //���������������������������������������������������������
2155     movieEndTimer = new Timer(2000, 1);
2156     movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, movieClipPlayCompleteWaitHandler);
2157     movieEndTimer.start();
2158    
2159    
2160     }
2161    
2162     /**
2163     *
2164     *
2165     */
2166     private function movieClipPlayCompleteWaitHandler(event:TimerEvent):void{
2167     if(!isCounted){
2168     //���������������������
2169     var videoId:String = LibraryUtil.getVideoKey(this.source);
2170     if(videoId == null){
2171     //���������������������������������������������������������
2172     videoId = LibraryUtil.getVideoKey(this.videoPlayer.title);
2173     }
2174     if(videoId != null){
2175     addVideoPlayCount(videoId, true);
2176     }
2177     isCounted = true;
2178     }
2179    
2180     logManager.addLog("***���������������***");
2181     this.lastFrame = 0;
2182     this.lastNicowariFrame = 0;
2183    
2184     if(videoPlayer.isRepeat){
2185     if(isPlayListingPlay){
2186     if(isStreamingPlay){
2187     logManager.addLog("***���������������������(���������������������)***");
2188     this.seek(0);
2189     }else{
2190     logManager.addLog("***���������������������(������������)***");
2191     this.stop();
2192     mc.gotoAndStop(0);
2193     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
2194     playingIndex, this.videoPlayer.title);
2195     }
2196     }else if(isStreamingPlay){
2197     logManager.addLog("***���������������������(���������������������)***");
2198     this.seek(0);
2199     }else{
2200     logManager.addLog("***���������������������(������������)***");
2201     this.stop();
2202     mc.gotoAndStop(0);
2203     this.play();
2204     }
2205     }else{
2206     this.stop();
2207     mc.gotoAndStop(0);
2208     if(isPlayListingPlay){
2209     logManager.addLog("***���������������(������������)***");
2210     var windowType:int = PlayerController.WINDOW_TYPE_FLV;
2211     if(playingIndex >= this.videoInfoView.getPlayList().length-1){
2212     playingIndex = 0;
2213     if(this.videoPlayer.videoInfoView.isRepeatAll()){
2214     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
2215     playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
2216     }
2217     }else{
2218     playingIndex++;
2219     playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
2220     playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
2221     }
2222     }
2223     }
2224    
2225     isMovieClipStopping = false;
2226     }
2227    
2228    
2229     /**
2230     * ���������������������ID������������������������������������������������������������1���������������
2231     * @param videoId ���������������������������������������������������ID
2232     * @param isSave ���������������������������������������������������
2233     */
2234     private function addVideoPlayCount(videoId:String, isSave:Boolean):void{
2235     var nnddVideo:NNDDVideo = libraryManager.isExist(videoId);
2236     if(nnddVideo != null){
2237     nnddVideo.playCount = nnddVideo.playCount + 1;
2238     libraryManager.update(nnddVideo, isSave);
2239     trace("���������������������:" + nnddVideo.videoName + "," + nnddVideo.playCount);
2240     }else{
2241     //���������������
2242