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