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