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