Develop and Download Open Source Software

Browse Subversion Repository

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

Parent Directory Parent Directory | Revision Log Revision Log


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