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 487 - (show annotations) (download)
Sat Apr 9 13:16:04 2011 UTC (13 years ago) by mineap
File size: 145794 byte(s)
Info画面の設定でスムージングを切り替えられるようにした(FLV/MP4で有効)
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 *
1171 * @param isSmoothing
1172 *
1173 */
1174 public function setVideoSmoothing(isSmoothing:Boolean):void{
1175
1176 if(videoDisplay != null && videoDisplay.videoObject != null){
1177 videoDisplay.videoObject.smoothing = isSmoothing;
1178 }
1179
1180 }
1181
1182 /**
1183 * videoDisplay���������������������������������������������������������������������������������������������
1184 * ���������������������������������������������������������������
1185 */
1186 public function resizePlayerJustVideoSize(windowSizeRatio:Number = -1):void{
1187
1188 try{
1189 var ratio:Number = 1;
1190 if(windowSizeRatio != -1){
1191 ratio = windowSizeRatio;
1192 }
1193
1194 //������������������������������
1195 var videoWindowHeight:int = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1196 var videoWindowWidth:int = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1197
1198 //���������������������������������
1199 var nicowariWindowHeight:int = PlayerController.NICO_WARI_HEIGHT * ratio;
1200 var nicowariWindowWidth:int = PlayerController.NICO_WARI_WIDTH * ratio;
1201
1202 //InfoView���������������������������������������
1203 if(isPlayListingPlay){
1204 if(this.videoInfoView != null){
1205 videoInfoView.showPlayingTitle(playingIndex);
1206 }
1207 }
1208
1209 //���������������������������������������
1210 if(this.videoPlayer.stage != null && this.videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE){
1211 //������������������������������������������ ������������������������������������������������������������
1212 if(this.videoInfoView.isResizePlayerEachPlay || windowSizeRatio != -1){
1213
1214 if(this.windowType == PlayerController.WINDOW_TYPE_FLV && this.videoDisplay != null && this.videoDisplay.videoObject != null){
1215 //FLV������������
1216
1217 // ���������������������������
1218
1219 this.videoDisplay.videoObject.smoothing = videoInfoView.isSmoothing;
1220
1221 if(this.videoInfoView.selectedResizeType == VideoInfoView.RESIZE_TYPE_NICO && this.videoDisplay.videoObject.videoHeight > 0){
1222
1223 //��������������������������������������������������������������� && ��������������������������������������������������� (���������������������������������������������������������������������������������)
1224 var isWideVideo:Boolean = false;
1225 if(WIDE_MODE_ASPECT_RATIO < Number(this.videoDisplay.videoObject.videoWidth)/Number(this.videoDisplay.videoObject.videoHeight)){
1226 // ���������������16:9���
1227 isWideVideo = true;
1228 trace("enable 16:9 mode");
1229 }
1230
1231 videoWindowHeight = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1232 if(this.videoInfoView.isEnableWideMode && isWideVideo){
1233 // logManager.addLog("���������(16:9)���������");
1234 videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH_WIDE_MODE * ratio;
1235 //������������������������������������������
1236 this.videoDisplay.setConstraintValue("left", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1237 this.videoDisplay.setConstraintValue("right", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1238
1239 }else{
1240 // logManager.addLog("������������(4:3)���������");
1241 videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1242 //������������������������������������������
1243 this.videoDisplay.setConstraintValue("left", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1244 this.videoDisplay.setConstraintValue("right", (PlayerController.NICO_VIDEO_WINDOW_WIDTH - PlayerController.NICO_SWF_WIDTH)/2);
1245
1246 }
1247
1248 if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1249 //init������������������������������������������������������������������������������������������������������������������
1250 videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1251 // resizePlayerJustVideoSize(windowSizeRatio);
1252 }
1253 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1254 videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1255 }
1256
1257 }else if(this.videoInfoView.selectedResizeType == VideoInfoView.RESIZE_TYPE_VIDEO && this.videoDisplay.videoObject.videoHeight > 0){
1258
1259 //���������������������������������������������������������������������(videoHeight���0���������������������������������������������������������������������)
1260
1261 videoWindowHeight = this.videoDisplay.videoObject.videoHeight * ratio;
1262 videoWindowWidth = this.videoDisplay.videoObject.videoWidth * ratio;
1263
1264 this.videoDisplay.setConstraintValue("bottom", 0);
1265 this.videoDisplay.setConstraintValue("left", 0);
1266 this.videoDisplay.setConstraintValue("right", 0);
1267 this.videoDisplay.setConstraintValue("top", 0);
1268
1269 if(videoDisplay.hasEventListener(LoadEvent.BYTES_LOADED_CHANGE)){
1270 //init������������������������������������������������������������������������������������������������������������������
1271 videoDisplay.removeEventListener(LoadEvent.BYTES_LOADED_CHANGE, byteloadedChangedEventHandler);
1272 // resizePlayerJustVideoSize(windowSizeRatio);
1273 }
1274 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1275 videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, osmfCurrentTimeChangeEventHandler);
1276 }
1277 }else{
1278 //������������������������������������������������
1279 return;
1280 }
1281
1282 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1283 //SWF������������
1284
1285 //SWF���������������������������������������
1286 videoWindowHeight = PlayerController.NICO_VIDEO_WINDOW_HEIGHT * ratio;
1287 videoWindowWidth = PlayerController.NICO_VIDEO_WINDOW_WIDTH * ratio;
1288
1289 }
1290
1291 //TODO ���������������VideoDisplay���������������������������������������������������������������
1292
1293 var rate:Number = PlayerController.NICO_WARI_WIDTH / PlayerController.NICO_WARI_HEIGHT;
1294 if(videoPlayer.canvas_nicowari.height < 1 ){
1295 //������������������������������������������������������������������������������������
1296 videoWindowHeight += int(videoWindowWidth / rate);
1297 }
1298
1299 this.videoPlayer.nativeWindow.height += int(videoWindowHeight - this.videoPlayer.canvas_video_back.height);
1300 this.videoPlayer.nativeWindow.width += int(videoWindowWidth - this.videoPlayer.canvas_video_back.width);
1301
1302 (this.videoPlayer as Window).validateDisplayList();
1303 (this.videoPlayer as Window).validateNow();
1304
1305 //������������������������������������������������������������������������������������������������������������������
1306 // var diffH:int = this.videoPlayer.nativeWindow.height - this.videoPlayer.stage.stageHeight;
1307 // var diffW:int = this.videoPlayer.nativeWindow.width - this.videoPlayer.stage.stageWidth;
1308
1309 }
1310
1311 }
1312
1313 }catch(error:Error){ //������������������������������������������������������������������������������������������
1314 trace(error.getStackTrace());
1315 logManager.addLog("������������������������������������������:" + error + ", " + error.getStackTrace());
1316 stop();
1317 destructor();
1318 }
1319 }
1320
1321
1322 /**
1323 * ������������������������������������������������������������������
1324 * ���������������������������������������������������������������������������������������������
1325 * @return
1326 *
1327 */
1328 public function play():void
1329 {
1330 try{
1331 videoPlayer.canvas_video_back.setFocus();
1332
1333 var newComments:Comments = null;
1334 videoPlayer.canvas_video.toolTip = null;
1335 if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
1336 if(videoDisplay != null && videoDisplay.playing){
1337 videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1338 videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1339 this.commentTimer.stop();
1340 this.commentTimer.reset();
1341 videoDisplay.pause();
1342 pausing = true;
1343 }else{
1344 videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
1345 videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
1346 if(pausing){
1347 this.videoPlayer.videoController.slider_timeline.enabled = true;
1348 this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1349 this.videoDisplay.play();
1350 this.time = (new Date).time;
1351 this.commentTimer.start();
1352 }else{
1353 this.videoPlayer.videoController.slider_timeline.enabled = true;
1354 this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1355 if(!isStreamingPlay){
1356 newComments = new Comments(PathMaker.createNomalCommentPathByVideoPath(source),
1357 PathMaker.createOwnerCommentPathByVideoPath(source), this.videoPlayer.getCommentListProvider(),
1358 this.videoPlayer.videoInfoView.ownerCommentProvider, this.ngListManager,
1359 this.videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
1360 this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable);
1361 init(source, PlayerController.WINDOW_TYPE_FLV, newComments, PathMaker.createThmbInfoPathByVideoPath(source), true, isStreamingPlay, null, this.isPlayListingPlay, this._videoID);
1362 }else{
1363 this.playMovie(source, null, -1, this.downLoadedURL);
1364 }
1365 }
1366 pausing = false;
1367 }
1368 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1369 if(isMovieClipPlaying){
1370 videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1371 videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1372 this.commentTimer.stop();
1373 this.commentTimer.reset();
1374 mc.stop();
1375 isMovieClipPlaying = false;
1376 pausing = true;
1377 }else{
1378 videoPlayer.videoController.button_play.setStyle("icon", icon_Pause);
1379 videoPlayer.videoController_under.button_play.setStyle("icon", icon_Pause);
1380 if(pausing){
1381 this.videoPlayer.videoController.slider_timeline.enabled = true;
1382 this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1383 mc.play();
1384 isMovieClipPlaying = true;
1385 this.time = (new Date).time;
1386 this.commentTimer.start();
1387 }else{
1388 this.videoPlayer.canvas_video.removeAllChildren();
1389 this.videoPlayer.videoController.slider_timeline.enabled = true;
1390 this.videoPlayer.videoController_under.slider_timeline.enabled = true;
1391 if(!isStreamingPlay){
1392 newComments = new Comments(PathMaker.createNomalCommentPathByVideoPath(source),
1393 PathMaker.createOwnerCommentPathByVideoPath(source), this.videoPlayer.getCommentListProvider(),
1394 this.videoPlayer.videoInfoView.ownerCommentProvider, this.ngListManager,
1395 this.videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
1396 this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable);
1397 init(source, PlayerController.WINDOW_TYPE_SWF, newComments, PathMaker.createThmbInfoPathByVideoPath(source), true, isStreamingPlay, null, this.isPlayListingPlay, this._videoID);
1398 }else{
1399 this.playMovie(source, null, -1, this.downLoadedURL);
1400 }
1401 }
1402 pausing = false;
1403 }
1404 }else{
1405 if(this.videoPlayer != null && this.videoPlayer.title != null){
1406 this.playMovie(this.videoPlayer.title);
1407 }
1408 }
1409
1410 }catch(error:Error){
1411 trace(error.getStackTrace());
1412 logManager.addLog("���������������������������:" + error + ":" + error.getStackTrace());
1413 }
1414
1415 }
1416
1417
1418 /**
1419 * ������������������������������������������������
1420 * @return
1421 *
1422 */
1423 public function stop():void
1424 {
1425 try{
1426
1427 pausing = false;
1428
1429 if(videoInfoView.isShowAlwaysNicowariArea){
1430 videoPlayer.showNicowariArea();
1431 }else{
1432 videoPlayer.hideNicowariArea();
1433 }
1434
1435 if(videoPlayer != null && videoPlayer.label_downloadStatus != null){
1436 videoPlayer.canvas_video_back.setFocus();
1437 videoPlayer.label_downloadStatus.text = "";
1438 videoPlayer.canvas_video.toolTip = "���������������������������������������������������������������������������������";
1439 }
1440
1441 if(this.movieEndTimer != null){
1442 this.movieEndTimer.stop();
1443 this.movieEndTimer = null;
1444 }
1445
1446 if(renewDownloadManager != null){
1447 try{
1448 renewDownloadManager.close();
1449 renewDownloadManager = null;
1450 logManager.addLog("���������������������������������������������������������");
1451 }catch(error:Error){
1452 trace(error);
1453 }
1454 }else{
1455
1456 this.videoPlayer.videoController.button_play.enabled = true;
1457 this.videoPlayer.videoController_under.button_play.enabled = true;
1458 videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1459 videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1460
1461 this.videoPlayer.videoController_under.slider_timeline.value = 0;
1462 this.videoPlayer.videoController.slider_timeline.value = 0;
1463
1464 this.commentTimerVpos = 0;
1465 this.commentTimer.stop();
1466 this.commentTimer.reset();
1467 this.commentManager.removeAll();
1468
1469 //���������������������������������������������
1470 this.destructor();
1471
1472 //������������������������������������������������������
1473 videoPlayer.canvas_nicowari.removeAllChildren();
1474 if(nicowariMC != null){
1475 this.pauseByNicowari(true);
1476 }
1477
1478 }
1479
1480 }catch(error:Error){
1481 trace(error.getStackTrace());
1482 logManager.addLog("������������������������������������������:" + error + ":" + error.getStackTrace());
1483 }
1484
1485 }
1486
1487
1488 /**
1489 * ���������������������������������������������������������������������������������
1490 *
1491 */
1492 public function goToTop():void
1493 {
1494 try{
1495
1496 pausing = false;
1497
1498 if(videoInfoView.isShowAlwaysNicowariArea){
1499 videoPlayer.showNicowariArea();
1500 }else{
1501 videoPlayer.hideNicowariArea();
1502 }
1503
1504 if(videoPlayer != null && videoPlayer.label_downloadStatus != null){
1505 videoPlayer.canvas_video_back.setFocus();
1506 videoPlayer.label_downloadStatus.text = "";
1507 videoPlayer.canvas_video.toolTip = "���������������������������������������������������������������������������������";
1508 }
1509
1510 if(this.movieEndTimer != null){
1511 this.movieEndTimer.stop();
1512 this.movieEndTimer = null;
1513 }
1514
1515 if(renewDownloadManager != null){
1516 try{
1517 renewDownloadManager.close();
1518 renewDownloadManager = null;
1519 logManager.addLog("���������������������������������������������������������");
1520 }catch(error:Error){
1521 trace(error);
1522 }
1523 }else{
1524
1525 this.videoPlayer.videoController.button_play.enabled = true;
1526 this.videoPlayer.videoController_under.button_play.enabled = true;
1527 videoPlayer.videoController.button_play.setStyle("icon", icon_Play);
1528 videoPlayer.videoController_under.button_play.setStyle("icon", icon_Play);
1529
1530 this.videoPlayer.videoController_under.slider_timeline.value = 0;
1531 this.videoPlayer.videoController.slider_timeline.value = 0;
1532
1533 this.commentTimerVpos = 0;
1534 this.commentTimer.stop();
1535 this.commentTimer.reset();
1536
1537 var playing:Boolean = false;
1538 if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
1539 if(videoDisplay != null && videoDisplay.playing){
1540 playing = true;
1541 }
1542 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1543 if(isMovieClipPlaying){
1544 playing = true;
1545 }
1546 }
1547
1548 if(playing){
1549 this.play();
1550 }
1551 this.seek(0);
1552
1553
1554 //������������������������������������������������������
1555 videoPlayer.canvas_nicowari.removeAllChildren();
1556 if(nicowariMC != null){
1557 this.pauseByNicowari(true);
1558 }
1559
1560 }
1561
1562 }catch(error:Error){
1563 trace(error.getStackTrace());
1564 logManager.addLog("������������������������������������������:" + error + ":" + error.getStackTrace());
1565 }
1566 }
1567
1568 /**
1569 * VideoDisplay���������������������������������������������������������
1570 * @param videoDisplay
1571 *
1572 */
1573 private function addVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1574 videoDisplay.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1575 videoDisplay.addEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1576 videoDisplay.addEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1577 }
1578
1579 /**
1580 * VideoDisplay���������������������������������������������������������
1581 * @param videoDisplay
1582 *
1583 */
1584 private function removeVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1585 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1586 videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1587 }
1588 if(videoDisplay.hasEventListener(TimeEvent.DURATION_CHANGE)){
1589 videoDisplay.removeEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1590 }
1591 if(videoDisplay.hasEventListener(VideoEvent.COMPLETE)){
1592 videoDisplay.removeEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1593 }
1594 }
1595
1596 /**
1597 *
1598 * @param event
1599 *
1600 */
1601 private function durationChangeEventHandler(event:TimeEvent):void{
1602 if(videoInfoView.isResizePlayerEachPlay){
1603 resizePlayerJustVideoSize(videoPlayer.nowRatio);
1604 }else{
1605 resizePlayerJustVideoSize();
1606 }
1607 }
1608
1609 /**
1610 *
1611 * @param loader
1612 *
1613 */
1614 // private function removeMovieClipEventHandlers(loader:Loader):void{
1615 // if(loader.hasEventListener(Event.COMPLETE)){
1616 // loader.removeEventListener(Event.COMPLETE, convertCompleteHandler);
1617 // }
1618 // }
1619
1620 /**
1621 * ������������������������������������������������������������������������������
1622 * @return
1623 *
1624 */
1625 public function getStreamingProgress():int{
1626 var value:int = 0;
1627 if(isStreamingPlay){
1628 if(videoDisplay != null){
1629 value = (videoDisplay.bytesLoaded*100 / videoDisplay.bytesTotal);
1630 }else if(loader != null && loader.contentLoaderInfo != null){
1631 value = (loader.contentLoaderInfo.bytesLoaded*100 / loader.contentLoaderInfo.bytesTotal);
1632 }else{
1633 value = 100;
1634 }
1635 }else{
1636 value = 100;
1637 }
1638 return value;
1639 }
1640
1641 /**
1642 *
1643 * @return
1644 *
1645 */
1646 public function get bytesLoaded():Number{
1647
1648 var value:Number = 0.0;
1649
1650 if(videoDisplay != null){
1651 value = videoDisplay.bytesLoaded;
1652 }else if(loader != null && loader.contentLoaderInfo != null){
1653 value = loader.contentLoaderInfo.bytesLoaded;
1654 }
1655
1656 return value;
1657 }
1658
1659 /**
1660 *
1661 * @param event
1662 *
1663 */
1664 private function streamingProgressHandler(event:TimerEvent):void{
1665 if(isStreamingPlay){
1666 var value:int = getStreamingProgress();
1667 if(value >= 100){
1668 this.videoPlayer.label_playSourceStatus.text = "Streaming:100%";
1669 streamingProgressCount = 0;
1670 videoPlayer.videoController.resetStatusAlpha();
1671 if(streamingProgressTimer != null){
1672 streamingProgressTimer.stop();
1673 }
1674
1675 // 100%���������������������������������������������������������������������������������������
1676 if(this.bytesLoaded <= 64){
1677 if(this.streamingRetryCount <= 3 ){
1678 // ���������������
1679 this.streamingRetryCount++;
1680 stop();
1681 logManager.addLog("���������������������������������������(���������������������������:������������������������������:" + this.bytesLoaded + ")");
1682 videoPlayer.label_downloadStatus.text = "������������������������������������������������������������������(" + this.streamingRetryCount +"������ )";
1683
1684 if(nicoVideoAccessRetryTimer != null){
1685 nicoVideoAccessRetryTimer.stop();
1686 nicoVideoAccessRetryTimer = null;
1687 }
1688 nicoVideoAccessRetryTimer = new Timer(5000*this.streamingRetryCount, 1);
1689 nicoVideoAccessRetryTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
1690 (event.currentTarget as Timer).stop();
1691 play();
1692 });
1693 nicoVideoAccessRetryTimer.start();
1694
1695 }else{
1696 stop();
1697 logManager.addLog("���������������������������:������������������������������:" + this.bytesLoaded);
1698 videoPlayer.label_downloadStatus.text = "���������������������������������������������(���������������������������������������������������)";
1699 }
1700 }else{
1701 // ������������������
1702 this.streamingRetryCount = 0;
1703 }
1704
1705 }else{
1706
1707 var str:String = " ";
1708 if(streamingProgressCount <= 10){
1709 str = ". ";
1710 }else if(streamingProgressCount > 10 && streamingProgressCount <= 20){
1711 str = ".. ";
1712 }else if(streamingProgressCount > 20 && streamingProgressCount <= 30){
1713 str = "...";
1714 }
1715
1716 this.videoPlayer.label_playSourceStatus.text = "Streaming:" + value + "%" + str;
1717 if(streamingProgressCount >= 30){
1718 streamingProgressCount = 0;
1719 }else{
1720 streamingProgressCount = streamingProgressCount + 2;
1721 }
1722 }
1723 }else{
1724 if(streamingProgressTimer != null){
1725 streamingProgressTimer.stop();
1726 }
1727 }
1728 }
1729
1730 /**
1731 * ������������������������������������������������������
1732 * @param evt
1733 *
1734 */
1735 private function currentTimeChangeEventHandler(event:TimeEvent = null):void{
1736 try{
1737 var allSec:String="00",allMin:String="0";
1738 var nowSec:String="00",nowMin:String="0";
1739
1740 this.commentTimerVpos = event.time*1000;
1741
1742 nowSec = String(int(this.videoDisplay.currentTime%60));
1743 nowMin = String(int(this.videoDisplay.currentTime/60));
1744
1745 allSec = String(int(this.videoDisplay.duration%60));
1746 allMin = String(int(this.videoDisplay.duration/60));
1747
1748 if(nowSec.length == 1){
1749 nowSec = "0" + nowSec;
1750 }
1751 if(allSec.length == 1){
1752 allSec = "0" + allSec;
1753 }
1754
1755 videoPlayer.videoController_under.slider_timeline.enabled = true;
1756 videoPlayer.videoController_under.slider_timeline.minimum = 0;
1757 videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1758 if(!this.sliderChanging){
1759
1760 this.videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1761 this.videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1762 videoPlayer.videoController_under.slider_timeline.value = videoDisplay.currentTime;
1763
1764 }
1765 videoPlayer.videoController_under.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1766 videoPlayer.videoController_under.slider_timeline.enabled = true;
1767
1768 videoPlayer.videoController.slider_timeline.enabled = true;
1769 videoPlayer.videoController.slider_timeline.minimum = 0;
1770 videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1771 if(!this.sliderChanging){
1772 videoPlayer.videoController.slider_timeline.value = videoDisplay.currentTime;
1773 }
1774 videoPlayer.videoController.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1775 videoPlayer.videoController.slider_timeline.enabled = true;
1776 }catch(error:Error){
1777 VideoDisplay(event.currentTarget).stop();
1778 trace(error.getStackTrace());
1779 }
1780 }
1781
1782 /**
1783 * ������������������������������������������������������������������������
1784 * @param evt
1785 *
1786 */
1787 private function videoDisplayCompleteHandler(evt:TimeEvent = null):void{
1788
1789 if(movieEndTimer != null){
1790 movieEndTimer.stop();
1791 movieEndTimer = null;
1792 }
1793 //���������������������������������������������������������
1794 movieEndTimer = new Timer(2000, 1);
1795 movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, videoPlayCompleteWaitHandler);
1796 movieEndTimer.start();
1797
1798 }
1799
1800 /**
1801 *
1802 *
1803 */
1804 private function videoPlayCompleteWaitHandler(event:TimerEvent):void{
1805 if(!isCounted){
1806 //���������������������
1807 var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
1808 if(videoId != null){
1809 addVideoPlayCount(videoId, true);
1810 }
1811 isCounted = true;
1812 }
1813
1814 logManager.addLog("***���������������***");
1815
1816 if(videoPlayer.isRepeat){
1817 if(isPlayListingPlay){
1818 if(isStreamingPlay){
1819 logManager.addLog("***���������������������(���������������������)***");
1820 this.seek(0);
1821 if(this.videoDisplay != null){
1822 this.videoDisplay.play();
1823 }
1824 }else{
1825 logManager.addLog("***���������������������(������������)***");
1826 this.stop();
1827 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList, playingIndex, this.videoPlayer.title);
1828
1829 }
1830 }else if(isStreamingPlay){
1831 logManager.addLog("***���������������������(���������������������)***");
1832 this.seek(0);
1833 if(this.videoDisplay != null){
1834 this.videoDisplay.play();
1835 }
1836 }else{
1837 logManager.addLog("***���������������������(������������)***");
1838 this.stop();
1839 this.play();
1840 }
1841 }else{
1842 this.stop();
1843 if(isPlayListingPlay){
1844 logManager.addLog("***���������������(������������)***");
1845 var windowType:int = PlayerController.WINDOW_TYPE_FLV;
1846 if(playingIndex >= this.videoInfoView.getPlayList().length-1){
1847 playingIndex = 0;
1848 if(this.videoPlayer.videoInfoView.isRepeatAll()){
1849 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1850 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1851 }
1852 }else{
1853 playingIndex++;
1854 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1855 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1856 }
1857 }
1858 }
1859 }
1860
1861
1862 /**
1863 * SWF������������������������������������������������������������������
1864 *
1865 */
1866 private function movieClipCompleteHandler():void{
1867
1868 this.lastFrame = 0;
1869 this.lastNicowariFrame = 0;
1870
1871 if(movieEndTimer != null){
1872 movieEndTimer.stop();
1873 movieEndTimer = null;
1874 }
1875 //���������������������������������������������������������
1876 movieEndTimer = new Timer(2000, 1);
1877 movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, movieClipPlayCompleteWaitHandler);
1878 movieEndTimer.start();
1879
1880
1881 }
1882
1883 /**
1884 *
1885 *
1886 */
1887 private function movieClipPlayCompleteWaitHandler(event:TimerEvent):void{
1888 if(!isCounted){
1889 //���������������������
1890 var videoId:String = LibraryUtil.getVideoKey(this.source);
1891 if(videoId == null){
1892 //���������������������������������������������������������
1893 videoId = LibraryUtil.getVideoKey(this.videoPlayer.title);
1894 }
1895 if(videoId != null){
1896 addVideoPlayCount(videoId, true);
1897 }
1898 isCounted = true;
1899 }
1900
1901 logManager.addLog("***���������������***");
1902 this.lastFrame = 0;
1903 this.lastNicowariFrame = 0;
1904
1905 if(videoPlayer.isRepeat){
1906 if(isPlayListingPlay){
1907 if(isStreamingPlay){
1908 logManager.addLog("***���������������������(���������������������)***");
1909 this.seek(0);
1910 }else{
1911 logManager.addLog("***���������������������(������������)***");
1912 this.stop();
1913 mc.gotoAndStop(0);
1914 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1915 playingIndex, this.videoPlayer.title);
1916 }
1917 }else if(isStreamingPlay){
1918 logManager.addLog("***���������������������(���������������������)***");
1919 this.seek(0);
1920 }else{
1921 logManager.addLog("***���������������������(������������)***");
1922 this.stop();
1923 mc.gotoAndStop(0);
1924 this.play();
1925 }
1926 }else{
1927 this.stop();
1928 mc.gotoAndStop(0);
1929 if(isPlayListingPlay){
1930 logManager.addLog("***���������������(������������)***");
1931 var windowType:int = PlayerController.WINDOW_TYPE_FLV;
1932 if(playingIndex >= this.videoInfoView.getPlayList().length-1){
1933 playingIndex = 0;
1934 if(this.videoPlayer.videoInfoView.isRepeatAll()){
1935 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1936 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1937 }
1938 }else{
1939 playingIndex++;
1940 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1941 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1942 }
1943 }
1944 }
1945
1946 isMovieClipStopping = false;
1947 }
1948
1949
1950 /**
1951 * ���������������������ID������������������������������������������������������������1���������������
1952 * @param videoId ���������������������������������������������������ID
1953 * @param isSave ���������������������������������������������������
1954 */
1955 private function addVideoPlayCount(videoId:String, isSave:Boolean):void{
1956 var nnddVideo:NNDDVideo = libraryManager.isExist(videoId);
1957 if(nnddVideo != null){
1958 nnddVideo.playCount = nnddVideo.playCount + 1;
1959 libraryManager.update(nnddVideo, isSave);
1960 trace("���������������������:" + nnddVideo.videoName + "," + nnddVideo.playCount);
1961 }else{
1962 //���������������
1963 trace("������������������������������������:" + videoId);
1964 }
1965 }
1966
1967 /**
1968 * ���������������������������������������������
1969 * swf���������������SWF���������������������������������������������������
1970 *
1971 * @param event
1972 *
1973 */
1974 private function commentTimerHandler(event:TimerEvent):void{
1975
1976 if(isPlayerClosing){
1977 if(commentTimer != null){
1978 commentTimer.stop();
1979 commentTimer.reset();
1980 }
1981 return;
1982 }
1983
1984 // ���������������
1985 this.setVolume(this.videoPlayer.videoController.slider_volume.value);
1986
1987 var nowSec:String="00",nowMin:String="0";
1988 nowSec = String(int(commentTimerVpos/1000%60));
1989 nowMin = String(int(commentTimerVpos/1000/60));
1990 if(nowSec.length == 1){
1991 nowSec = "0" + nowSec;
1992 }
1993 var nowTime:String = nowMin + ":" + nowSec;
1994
1995 var allSec:String="00",allMin:String="0"
1996 if(this.windowType==PlayerController.WINDOW_TYPE_SWF && this.mc != null){
1997 allSec = String(int(mc.totalFrames/swfFrameRate%60));
1998 allMin = String(int(mc.totalFrames/swfFrameRate/60));
1999 }else if(this.windowType==PlayerController.WINDOW_TYPE_FLV && this.videoDisplay != null){
2000 allSec = String(int(videoDisplay.duration%60));
2001 allMin = String(int(videoDisplay.duration/60));
2002 }
2003 if(allSec.length == 1){
2004 allSec = "0" + allSec;
2005 }
2006 var allTime:String = allMin +":" + allSec;
2007
2008 if(!isCounted && commentTimerVpos > 10000){
2009 //���������������������
2010 var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
2011 if(videoId != null){
2012 addVideoPlayCount(videoId, false);
2013 }
2014 isCounted = true;
2015 }
2016
2017 //SWF���������������������������������������������������������������������
2018 if(isMovieClipPlaying && this.windowType==PlayerController.WINDOW_TYPE_SWF && this.mc != null){
2019
2020 videoPlayer.videoController_under.slider_timeline.enabled = true;
2021 videoPlayer.videoController_under.slider_timeline.minimum = 0;
2022 videoPlayer.videoController_under.slider_timeline.maximum = mc.totalFrames;
2023
2024 videoPlayer.videoController.slider_timeline.enabled = true;
2025 videoPlayer.videoController.slider_timeline.minimum = 0;
2026 videoPlayer.videoController.slider_timeline.maximum = mc.totalFrames;
2027
2028 if(!this.sliderChanging){
2029 videoPlayer.videoController_under.slider_timeline.value = mc.currentFrame;
2030 videoPlayer.videoController.slider_timeline.value = mc.currentFrame;
2031 }
2032
2033 // trace(nowMin + "/" + nowSec);
2034
2035 videoPlayer.videoController_under.label_time.text = nowTime + "/"+ allTime;
2036 videoPlayer.videoController.label_time.text = nowTime + "/"+ allTime;
2037
2038 if(mc.currentFrame >= mc.totalFrames-1 || mc.currentFrame == this.lastFrame ){
2039 this.lastFrame = mc.currentFrame;
2040 //���������movieClip������������������������������������������������������
2041 if(!isMovieClipStopping){
2042 isMovieClipStopping = true;
2043 movieClipCompleteHandler();
2044 }
2045 return;
2046 }else{
2047 if(!isMovieClipStopping){
2048 this.lastFrame = mc.currentFrame;
2049 }
2050 }
2051 }
2052
2053 var tempTime:Number = (new Date).time;
2054
2055 //SWF������������������������������������������������������������������
2056 if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
2057 this.commentTimerVpos += (tempTime - this.time);
2058 }
2059
2060 //���������������������
2061 var commentArray:Vector.<NNDDComment> = this.commentManager.setComment(commentTimerVpos, (tempTime - this.time)*3, this.videoPlayer.isShowComment);
2062 this.commentManager.moveComment(tempTime/1000 - this.time/1000, videoInfoView.showCommentSec);
2063 this.commentManager.removeComment(commentTimerVpos, videoInfoView.showCommentSec * 1000);
2064 this.time = tempTime;
2065
2066 //������������������������������������������������������
2067 if(videoPlayer.videoInfoView.checkbox_SyncComment.selected && videoPlayer.videoInfoView.visible
2068 // && (videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE
2069 // && videoInfoView.isActive)
2070 ){
2071
2072 var lastMin:String = commentManager.getComments().lastMin;
2073
2074 var tempNowTime:String = nowTime;
2075 if(lastMin.length == 3){
2076 //���������������3���������������:���������������������
2077 if(tempNowTime.length == 4){
2078 //���������������:������������4���
2079 tempNowTime = "00" + tempNowTime;
2080 }else if(tempNowTime.length == 5){
2081 //���������������:������������5���
2082 tempNowTime = "0" + tempNowTime;
2083 }
2084 }else if(lastMin.length == 2){
2085 //���������������2���������������:������������5������
2086 if(tempNowTime.length == 4){
2087 //���������������:������������4���
2088 tempNowTime = "0" + tempNowTime;
2089 }
2090
2091 }else if(lastMin.length == 1){
2092 //���������������1���������������:������������4������
2093
2094 }
2095
2096 if(tempNowTime.length > lastMin.length+3){
2097 tempNowTime = tempNowTime.substring(1);
2098 }
2099
2100
2101 var index:int = 0;
2102 if(commentArray.length > 0 && comments != null){
2103 var myComment:NNDDComment = commentArray[0];
2104 for each(var comment:NNDDComment in commentArray){
2105 if(comment.vpos > myComment.vpos){
2106 myComment = comment;
2107 }
2108 }
2109 index = comments.getCommentIndex(tempNowTime, myComment.text);
2110
2111 if(this.videoPlayer.videoInfoView.tabNavigator_comment.selectedIndex == 0){
2112
2113 if(this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition < index){
2114 index = index - (this.videoPlayer.videoInfoView.dataGrid_comment.rowCount) + 2;
2115 if(index > 0){
2116 if(index < this.videoPlayer.videoInfoView.dataGrid_comment.maxVerticalScrollPosition){
2117 this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = index;
2118 }else{
2119 this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = this.videoPlayer.videoInfoView.dataGrid_comment.maxVerticalScrollPosition;
2120 }
2121 }
2122 }
2123
2124 }else if(this.videoPlayer.videoInfoView.tabNavigator_comment.selectedIndex == 1){
2125
2126 if(this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition < index){
2127 index = index - (this.videoPlayer.videoInfoView.dataGrid_oldComment.rowCount) + 2;
2128 if(index > 0){
2129 if(index < this.videoPlayer.videoInfoView.dataGrid_oldComment.maxVerticalScrollPosition){
2130 this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition = index;
2131 }else{
2132 this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition = this.videoPlayer.videoInfoView.dataGrid_oldComment.maxVerticalScrollPosition;
2133 }
2134 }
2135 }
2136
2137 }
2138
2139 }
2140 }
2141
2142
2143 //������������������������
2144 var date:Date = new Date();
2145 var hh:String = new String(int(date.getHours()));
2146 var mm:String = new String(int(date.getMinutes()));
2147 if(hh.length == 1){
2148 hh = "0" + hh;
2149 }
2150 if(mm.length == 1){
2151 mm = "0" + mm;
2152 }
2153 var jihouResult:Array = commentManager.isJihouSettingTime(hh + mm);
2154 if(jihouResult != null && playingJihou == null){
2155 //������������
2156 playingJihou = hh+mm;
2157 playNicowari(jihouResult[0], jihouResult[1]);
2158 }
2159 if(playingJihou != null && playingJihou != (hh+mm)){
2160 playingJihou = null;
2161 }
2162
2163 if(!this.videoPlayer.isShowComment){
2164 this.commentManager.removeAll();
2165 }
2166
2167 }
2168
2169 /**
2170 * ������������������������������������������������������������������������
2171 * @param volume 0������1���������������������������������������������
2172 * @return ������������������������������������
2173 *
2174 */
2175 public function setVolume(volume:Number):Number{
2176 if(this.windowReady){
2177 if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
2178 if(videoDisplay != null){
2179 videoDisplay.volume = volume;
2180 this.videoPlayer.videoController.slider_volume.value = volume;
2181 this.videoPlayer.videoController_under.slider_volume.value = volume;
2182 return videoDisplay.volume;
2183 }
2184 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
2185 if(mc != null){
2186 var transForm:SoundTransform = new SoundTransform(volume, 0);
2187 mc.soundTransform = transForm;
2188 this.videoPlayer.videoController.slider_volume.value = volume;
2189 this.videoPlayer.videoController_under.slider_volume.value = volume;
2190 return mc.soundTransform.volume;
2191 }
2192 }
2193 }
2194 return 0;
2195 }
2196
2197 /**
2198 * PlayerController���������������CommentManager������������������
2199 * @return
2200 *
2201 */
2202 public function getCommentManager():CommentManager{
2203 return commentManager;
2204 }
2205
2206 /**
2207 * ���������������������������������������������������������������������������������������������������
2208 * ���������SWF������������������������������������������������������������������������Loader������������������������������������������������������
2209 */
2210 public function windowResized(isCommentRemove:Boolean):void{
2211
2212 if(this.windowReady){
2213
2214 //SWFLoader���������������������������������������
2215 if(swfLoader != null && this.windowType == PlayerController.WINDOW_TYPE_SWF){
2216 //������������������
2217
2218 (swfLoader.getChildAt(0) as Loader).x = 0;
2219 (swfLoader.getChildAt(0) as Loader).y = 0;
2220 var flashDistX:int = (swfLoader.getChildAt(0) as Loader).width - PlayerController.NICO_SWF_WIDTH;
2221 var flashDistY:int = (swfLoader.getChildAt(0) as Loader).height - PlayerController.NICO_SWF_HEIGHT;
2222 var scaleX:Number = swfLoader.width / ((swfLoader.getChildAt(0) as Loader).width - flashDistX);
2223 var scaleY:Number = swfLoader.height / ((swfLoader.getChildAt(0) as Loader).height - flashDistY);
2224 if(scaleX < scaleY){
2225 (swfLoader.getChildAt(0) as Loader).scaleX = scaleX;
2226 (swfLoader.getChildAt(0) as Loader).scaleY = scaleX;
2227 var centorY:int = swfLoader.height / 2;
2228 var newY:int = centorY - (PlayerController.NICO_SWF_HEIGHT*scaleX)/2;
2229 // trace("newY:"+newY);
2230 if(newY > 0){
2231 (swfLoader.getChildAt(0) as Loader).y = newY;
2232 }
2233 }else{
2234 (swfLoader.getChildAt(0) as Loader).scaleX = scaleY;
2235 (swfLoader.getChildAt(0) as Loader).scaleY = scaleY;
2236 var centorX:int = swfLoader.width / 2;
2237 var newX:int = centorX - (PlayerController.NICO_SWF_WIDTH*scaleY)/2;
2238 // trace("newX:"+newX);
2239 if(newX > 0){
2240 (swfLoader.getChildAt(0) as Loader).x = newX;
2241 }
2242 }
2243
2244 }
2245
2246 //���������SWF������������������������������������������
2247 if(nicowariSwfLoader != null){
2248
2249 (nicowariSwfLoader.getChildAt(0) as Loader).x = 0;
2250 (nicowariSwfLoader.getChildAt(0) as Loader).y = 0;
2251
2252 var nicowariDistX:Number = (nicowariSwfLoader.getChildAt(0) as Loader).width - PlayerController.NICO_WARI_WIDTH;
2253 var nicowariDistY:Number = (nicowariSwfLoader.getChildAt(0) as Loader).height - PlayerController.NICO_WARI_HEIGHT;
2254
2255 var nicowariScaleX:Number = nicowariSwfLoader.width / ((nicowariSwfLoader.getChildAt(0) as Loader).width - nicowariDistX);
2256 var nicowariScaleY:Number = nicowariSwfLoader.height / ((nicowariSwfLoader.getChildAt(0) as Loader).height - nicowariDistY);
2257 if(nicowariScaleX < nicowariScaleY){
2258 (nicowariSwfLoader.getChildAt(0) as Loader).scaleX = nicowariScaleX;
2259 (nicowariSwfLoader.getChildAt(0) as Loader).scaleY = nicowariScaleX;
2260 centorY = nicowariSwfLoader.height / 2;
2261 newY = centorY - (PlayerController.NICO_WARI_HEIGHT*nicowariScaleX)/2;
2262 // trace("newY:"+newY);
2263 if(newY > 0){
2264 (nicowariSwfLoader.getChildAt(0) as Loader).y = newY;
2265 }
2266 }else{
2267 (nicowariSwfLoader.getChildAt(0) as Loader).scaleX = nicowariScaleY;
2268 (nicowariSwfLoader.getChildAt(0) as Loader).scaleY = nicowariScaleY;
2269 centorX = nicowariSwfLoader.width / 2;
2270 newX = centorX - (PlayerController.NICO_WARI_WIDTH*nicowariScaleY)/2;
2271 // trace("newX:"+newX);
2272 if(newX > 0){
2273 (nicowariSwfLoader.getChildAt(0) as Loader).x = newX;
2274 }
2275 }
2276 }
2277
2278 if(isCommentRemove){
2279 // ���������������������������
2280 commentManager.removeAll();
2281 }else{
2282 // ���������������������������������
2283 commentManager.validateCommentPosition();
2284 }
2285
2286
2287
2288 }
2289 }
2290
2291 /**
2292 * ���������������seekTime������������������������������������������������
2293 * @param seekTime ������������������������������������������������������������������������������������������������������
2294 *
2295 */
2296 public function seek(seekTime:Number):void{
2297 trace(seekTime);
2298 if(this.windowReady){
2299 if((new Date().time)-lastSeekTime > 1000){
2300 if((videoDisplay != null && videoDisplay.initialized && videoDisplay.duration > 0) || (swfLoader != null && swfLoader.initialized)){
2301
2302
2303 trace("seekStart:" + seekTime);
2304 this.commentTimer.stop();
2305 this.commentTimer.reset();
2306
2307 //������������������������������������������������������
2308 commentManager.getComments().resetEnableShowFlag();
2309
2310 //���������������������������������������������
2311 this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = 0;
2312
2313 if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
2314 videoDisplay.seek(seekTime);
2315 commentTimerVpos = seekTime*1000;
2316 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
2317 mc.gotoAndPlay(int(seekTime));
2318 commentTimerVpos = (seekTime/swfFrameRate)*1000;
2319 }
2320
2321 commentManager.removeAll();
2322
2323 if(!this.pausing || this.windowType == PlayerController.WINDOW_TYPE_SWF){
2324 commentTimer.start();
2325 }
2326 lastSeekTime = new Date().time;
2327
2328
2329
2330 }
2331 }
2332 }
2333 }
2334
2335
2336 /**
2337 * ������Player������������������������������������������������
2338 * @return Player���������������������������true������������������������������false���
2339 *
2340 */
2341 public function isOpen():Boolean{
2342 if(this.videoPlayer.nativeWindow != null){
2343 return !this.videoPlayer.closed;
2344 }
2345 return false;
2346 }
2347
2348 /**
2349 * Player������������������Open������������
2350 *
2351 */
2352 public function open():Boolean{
2353 if(this.videoPlayer != null){
2354 this.videoPlayer.open();
2355 }else{
2356 return false;
2357 }
2358 if(this.videoInfoView != null){
2359 this.videoInfoView.open();
2360 }else{
2361 return false;
2362 }
2363 return true;
2364 }
2365
2366 /**
2367 * ���������������������Player������������������������������
2368 *
2369 */
2370 public function playerExit():void{
2371
2372 this.stop();
2373 if(this.videoPlayer != null && this.videoPlayer.nativeWindow != null && !this.videoPlayer.closed){
2374 this.videoPlayer.restore();
2375 // this.videoPlayer.saveStore();
2376 this.videoPlayer.close();
2377 }
2378 if(this.videoPlayer != null && this.videoInfoView.nativeWindow != null && !this.videoInfoView.closed){
2379 this.saveNgList();
2380 this.videoInfoView.restore();
2381 // this.videoInfoView.saveStore();
2382 this.videoInfoView.close();
2383 }
2384 }
2385
2386 /**
2387 *
2388 * @param url
2389 *
2390 */
2391 public function reload(url:String):void
2392 {
2393
2394 stop();
2395
2396 playMovie(url);
2397
2398 }
2399
2400 /**
2401 * ���������NG���������������������������������
2402 *
2403 */
2404 public function saveNgList():void{
2405 this.ngListManager.saveNgList(LibraryManagerBuilder.instance.libraryManager.systemFileDir);
2406 }
2407
2408 public function getCommentListProvider():ArrayCollection{
2409 return this.videoPlayer.getCommentListProvider();
2410 }
2411
2412 public function getOwnerCommentListProvider():ArrayCollection{
2413 return this.videoPlayer.videoInfoView.ownerCommentProvider;
2414 }
2415
2416
2417 /**
2418 * ������������������NG���������������������������������������������������
2419 * @param date ������������������������������������
2420 */
2421 public function reloadLocalComment(date:Date = null):void{
2422
2423 if(date != null){
2424 trace(date.time);
2425 }
2426
2427 if(this.videoInfoView.ngListProvider != null){
2428 if(!this.isStreamingPlay && this.source != null && this.source != "" ){
2429 comments = new Comments(PathMaker.createNomalCommentPathByVideoPath(source),
2430 PathMaker.createOwnerCommentPathByVideoPath(source), videoPlayer.getCommentListProvider(),
2431 this.videoPlayer.videoInfoView.ownerCommentProvider, this.ngListManager,
2432 this.videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
2433 this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable, date);
2434 }else if(this.isStreamingPlay){
2435 comments = new Comments(PathMaker.createNomalCommentPathByVideoPath(LibraryManagerBuilder.instance.libraryManager.tempDir.url + "/nndd.flv"),
2436 PathMaker.createOwnerCommentPathByVideoPath(LibraryManagerBuilder.instance.libraryManager.tempDir.url + "/nndd.flv"),
2437 this.videoPlayer.getCommentListProvider(), this.videoPlayer.videoInfoView.ownerCommentProvider,
2438 this.ngListManager, videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
2439 this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable, date);
2440 }
2441 commentManager.setComments(comments);
2442 }
2443
2444 this.windowResized(true);
2445
2446 }
2447
2448 /**
2449 * ���������������������������������������������������������������
2450 * @param videoPath
2451 *
2452 */
2453 private function setInfo(videoPath:String, thumbInfoPath:String, ichibaInfoPath:String, isStreaming:Boolean):void{
2454
2455 var videoID:String = PathMaker.getVideoID(videoPath);
2456
2457 if(!isStreaming){ //������������������������������������������������������������������������������������������������������������������������������
2458
2459 if(videoID != null && (mailAddress != null && password != null) && (mailAddress != "" && password != "") ){
2460
2461 //���������
2462 videoInfoView.ichibaNicoProvider.addItem({
2463 col_image:"",
2464 col_info:"������������������������������",
2465 col_link:""
2466 });
2467 videoPlayer.videoInfoView.owner_text_nico = "";
2468
2469 }else{
2470 videoInfoView.ichibaNicoProvider.addItem({
2471 col_image:"",
2472 col_info:"������������������������������������������������",
2473 col_link:""
2474 });
2475
2476 var thumbInfoAnalyzer:ThumbInfoAnalyzer = null;
2477
2478 if(videoPath != null){
2479
2480 var thumbInfoPath:String = PathMaker.createThmbInfoPathByVideoPath(videoPath);
2481
2482 var fileIO:FileIO = new FileIO(logManager);
2483 var xml:XML = fileIO.loadXMLSync(thumbInfoPath, false);
2484
2485 if(xml != null){
2486 thumbInfoAnalyzer = new ThumbInfoAnalyzer(xml);
2487 }
2488 }
2489
2490 if(thumbInfoAnalyzer != null){
2491
2492 var dateString:String = "(������������������������������)";
2493 var ownerText:String = "(������������������������������������)";
2494 var htmlInfo:String = "";
2495
2496 if(thumbInfoAnalyzer != null){
2497 var dateFormatter:DateFormatter = new DateFormatter();
2498 dateFormatter.formatString = "YYYY/MM/DD JJ:NN:SS";
2499 var date:Date = thumbInfoAnalyzer.getDateByFirst_retrieve();
2500 dateString = "���������:(������������������������)";
2501 if(date != null){
2502 dateString = "���������:" + dateFormatter.format(date);
2503 }
2504
2505 htmlInfo = thumbInfoAnalyzer.htmlTitle + "<br />" + dateString + "<br />" + thumbInfoAnalyzer.playCountAndCommentCountAndMyListCount;
2506
2507 ownerText = thumbInfoAnalyzer.thumbInfoHtml + "\n(���������������������������������)";
2508 }else{
2509
2510 if(videoPlayer.videoInfoView.owner_text_local.length > 1){
2511 ownerText = videoPlayer.videoInfoView.owner_text_local + "\n(���������������������������������)";
2512 }
2513
2514 htmlInfo = "(������������������������������)<br />" + dateString + "<br />(���������������������������������)";
2515 }
2516
2517 videoPlayer.videoInfoView.text_info.htmlText = htmlInfo;
2518
2519 if(videoPlayer.videoInfoView.checkbox_showHtml.selected){
2520 videoPlayer.videoInfoView.owner_text_temp = videoPlayer.videoInfoView.owner_text_nico;
2521 videoPlayer.videoInfoView.owner_text_nico = ownerText;
2522 }else{
2523 videoPlayer.videoInfoView.owner_text_temp = ownerText;
2524 }
2525
2526 videoPlayer.videoInfoView.nicoTagProvider = thumbInfoAnalyzer.tagArray;
2527 videoPlayer.videoInfoView.nicoTagProvider.push("(���������������������������������������������������������������)");
2528 videoPlayer.setTagArray(videoPlayer.videoInfoView.nicoTagProvider);
2529
2530 }else{
2531
2532 videoPlayer.videoInfoView.text_info.htmlText = "(������������������������������)<br />(������������������������������)<br />(���������������������������������)";
2533 videoPlayer.videoInfoView.owner_text_nico = "(������������������������������)";
2534
2535 videoPlayer.videoInfoView.nicoTagProvider = videoPlayer.videoInfoView.localTagProvider;
2536 videoPlayer.videoInfoView.nicoTagProvider.push("(���������������������������������������������������������������)");
2537 videoPlayer.setTagArray(videoPlayer.videoInfoView.nicoTagProvider);
2538
2539 }
2540 }
2541 }
2542
2543 if(videoID != null && (mailAddress != null && password != null) && (mailAddress != "" && password != "") ){
2544 retryCount = 0;
2545 setNicoVideoPageInfo(PathMaker.getVideoID(videoID), 0, isStreaming); //���������������������������������������������������
2546 }
2547
2548 setNicoRelationInfo(videoID); //������������������������������������������������������������������������������
2549
2550 setLocalIchibaInfo(ichibaInfoPath, isStreaming);
2551 setLocalThumbInfo(videoID, thumbInfoPath, isStreaming);
2552
2553 }
2554
2555
2556
2557 //-------------------------------------------------------
2558
2559 /**
2560 * ������������������������������������
2561 *
2562 */
2563 public function setNicoRelationInfoForRelationSortTypeChange():void{
2564 var videoId:String = PathMaker.getVideoID(videoPlayer.title);
2565 if(videoId != null){
2566 setNicoRelationInfo(videoId);
2567 }
2568 }
2569
2570 /**
2571 * ������������������������������������������������������������������������
2572 * @param videoID
2573 *
2574 */
2575 private function setNicoRelationInfo(videoID:String):void{
2576
2577 (videoInfoView.relationDataProvider as ArrayCollection).removeAll();
2578
2579 if(videoInfoView == null){
2580 return;
2581 }
2582
2583 if(nicoRelationInfoLoader != null){
2584 try{
2585 nicoRelationInfoLoader.close();
2586 }catch(error:Error){
2587 }
2588 }
2589
2590 videoInfoView.setRelationComboboxEnable(false);
2591
2592 var sort:String = RelationTypeUtil.convertRelationSortType(videoInfoView.relationSortIndex);
2593 var order:String = RelationTypeUtil.convertRelationOrderType(videoInfoView.relationOrderIndex);
2594
2595 logManager.addLog("���������������������������������(videoId:" + videoID + ", sort:" + sort + ", order:" + order + ")");
2596
2597 nicoRelationInfoLoader = new ApiGetRelation();
2598 nicoRelationInfoLoader.addEventListener(Event.COMPLETE, function(event:Event):void{
2599 (videoInfoView.relationDataProvider as ArrayCollection).removeAll();
2600 var analyzer:GetRelationResultAnalyzer = new GetRelationResultAnalyzer();
2601 analyzer.analyze(event.currentTarget.data);
2602 try{
2603 event.currentTarget.close();
2604 }catch(error:Error){
2605 }
2606
2607 if("ok" == analyzer.status){
2608 for each(var item:RelationResultItem in analyzer.videos){
2609 var pubDate:Date = new Date(item.time * 1000);
2610 var info:String = HtmlUtil.convertSpecialCharacterNotIncludedString(item.title) + "\n" +
2611 "\t������������:" + NumberUtil.addComma(String(item.view)) + "\n" +
2612 "\t���������������:" + NumberUtil.addComma(String(item.mylist)) + ", ���������������:" + NumberUtil.addComma(String(item.comment)) + "\n" +
2613 "\t���������:" + DateUtil.getDateString(pubDate);
2614 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2615 col_image:item.thumbnail,
2616 col_info:info,
2617 col_link:item.url
2618 });
2619 }
2620 if(videoInfoView.datagrid_relation != null){
2621 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2622 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2623 }
2624 logManager.addLog("���������������������������������:" + event);
2625 videoInfoView.setRelationComboboxEnable(true);
2626
2627 }else{
2628 logManager.addLog("���������������������������������:status=" + analyzer.status + "," + event);
2629 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2630 col_image:"",
2631 col_info:"������������������������������������(status=" + analyzer.status + ")",
2632 col_link:null
2633 });
2634 if(videoInfoView.datagrid_relation != null){
2635 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2636 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2637 }
2638 videoInfoView.setRelationComboboxEnable(true);
2639 }
2640
2641 });
2642 nicoRelationInfoLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, function(event:HTTPStatusEvent):void{
2643 logManager.addLog("\t" + event.toString());
2644 });
2645 nicoRelationInfoLoader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{
2646 (videoInfoView.relationDataProvider as ArrayCollection).removeAll();
2647 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2648 col_image:"",
2649 col_info:"������������������������������������(���������������)",
2650 col_link:null
2651 });
2652 logManager.addLog("������������������������������������:" + event);
2653 try{
2654 event.currentTarget.close();
2655 }catch(error:Error){
2656 trace(error.getStackTrace());
2657 }
2658 if(videoInfoView.datagrid_relation != null){
2659 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2660 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2661 }
2662 videoInfoView.setRelationComboboxEnable(true);
2663 });
2664 nicoRelationInfoLoader.getRelation(videoID, 1, sort, order);
2665
2666 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2667 col_image:"",
2668 col_info:"������������������������������������������...",
2669 col_link:null
2670 });
2671 if(videoInfoView.datagrid_relation != null){
2672 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2673 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2674 }
2675
2676 }
2677
2678 /**
2679 * ������������������������������������������
2680 */
2681 private var retryCount:int = 0;
2682
2683 /**
2684 * ���������������������������������������������������������������������������������������������������������<br />
2685 * ���������������������
2686 * ������������������������������������������
2687 * ������������������������
2688 * ���������������
2689 * ������������������
2690 *
2691 * @param videoId
2692 * @param delay
2693 *
2694 */
2695 private function setNicoVideoPageInfo(videoId:String, delay:int, onlyOwnerText:Boolean = false):void{
2696
2697 if(retryCount > 5){
2698 trace("setNicoVideoPageInfo���������������������������");
2699 logManager.addLog("���������������������������������������������(������������������������):" + _videoID);
2700 return;
2701 }else{
2702 logManager.addLog("������������������������������������������(������������:" + retryCount + "):" + _videoID);
2703 }
2704 retryCount++;
2705
2706 if(delay == 0){
2707 getInfo(onlyOwnerText);
2708 }else{
2709 if(nicoVideoPageGetRetryTimer != null){
2710 nicoVideoPageGetRetryTimer.stop();
2711 nicoVideoPageGetRetryTimer = null;
2712 }
2713
2714 nicoVideoPageGetRetryTimer = new Timer(delay, 1);
2715 nicoVideoPageGetRetryTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
2716 trace("getInfo���������������:" + retryCount + "���");
2717 (event.currentTarget as Timer).stop();
2718 getInfo(onlyOwnerText);
2719 });
2720 nicoVideoPageGetRetryTimer.start();
2721 }
2722
2723 function getInfo(onlyOwnerText:Boolean):void{
2724 var watchVideoPage:NNDDVideoPageWatcher = new NNDDVideoPageWatcher();
2725 watchVideoPage.addEventListener(NNDDVideoPageWatcher.SUCCESS, function(event:Event):void{
2726
2727 try{
2728 var fail:Boolean = false;
2729
2730 var description:String = watchVideoPage.watcher.getDescription();
2731 if(description != null && description.length > 0 ){
2732
2733 // videoPlayer.videoInfoView.owner_text_nico = ThumbInfoUtil.encodeThumbInfo(description);
2734
2735 if(videoPlayer.videoInfoView.checkbox_showHtml.selected){
2736 videoPlayer.videoInfoView.owner_text_temp = videoPlayer.videoInfoView.owner_text_nico;
2737 videoPlayer.videoInfoView.owner_text_nico = ThumbInfoUtil.encodeThumbInfo(description);
2738 }else{
2739 videoPlayer.videoInfoView.owner_text_temp = ThumbInfoUtil.encodeThumbInfo(description);
2740 }
2741
2742 }else{
2743 fail = true;
2744 }
2745
2746 if(