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 418 - (show annotations) (download)
Sat Jan 8 10:33:24 2011 UTC (13 years, 3 months ago) by mineap
File size: 140852 byte(s)
再生開始時にウィンドウサイズが正しく変更されなかったのを修正
1 package org.mineap.nndd.player
2 {
3 import flash.display.Loader;
4 import flash.display.LoaderInfo;
5 import flash.display.MovieClip;
6 import flash.display.NativeWindowType;
7 import flash.display.StageDisplayState;
8 import flash.events.ErrorEvent;
9 import flash.events.Event;
10 import flash.events.EventDispatcher;
11 import flash.events.HTTPStatusEvent;
12 import flash.events.IOErrorEvent;
13 import flash.events.MouseEvent;
14 import flash.events.TimerEvent;
15 import flash.filesystem.File;
16 import flash.media.SoundMixer;
17 import flash.media.SoundTransform;
18 import flash.net.URLRequest;
19 import flash.utils.Timer;
20
21 import mx.collections.ArrayCollection;
22 import mx.controls.Alert;
23 import mx.controls.DataGrid;
24 import mx.controls.SWFLoader;
25 import mx.controls.Text;
26 import mx.controls.videoClasses.VideoError;
27 import mx.core.FlexGlobals;
28 import mx.core.Window;
29 import mx.events.AIREvent;
30 import mx.events.FlexEvent;
31 import mx.events.MetadataEvent;
32 import mx.events.VideoEvent;
33 import mx.formatters.DateFormatter;
34
35 import org.libspark.utils.ForcibleLoader;
36 import org.mineap.nicovideo4as.MyListLoader;
37 import org.mineap.nicovideo4as.WatchVideoPage;
38 import org.mineap.nicovideo4as.analyzer.GetRelationResultAnalyzer;
39 import org.mineap.nicovideo4as.loader.api.ApiGetRelation;
40 import org.mineap.nicovideo4as.model.RelationResultItem;
41 import org.mineap.nicovideo4as.util.HtmlUtil;
42 import org.mineap.nndd.Access2Nico;
43 import org.mineap.nndd.FileIO;
44 import org.mineap.nndd.LogManager;
45 import org.mineap.nndd.Message;
46 import org.mineap.nndd.NNDDDownloader;
47 import org.mineap.nndd.NNDDVideoPageWatcher;
48 import org.mineap.nndd.RenewDownloadManager;
49 import org.mineap.nndd.history.HistoryManager;
50 import org.mineap.nndd.library.ILibraryManager;
51 import org.mineap.nndd.library.LibraryManagerBuilder;
52 import org.mineap.nndd.library.LocalVideoInfoLoader;
53 import org.mineap.nndd.model.NNDDComment;
54 import org.mineap.nndd.model.NNDDVideo;
55 import org.mineap.nndd.model.PlayList;
56 import org.mineap.nndd.playList.PlayListManager;
57 import org.mineap.nndd.player.comment.Command;
58 import org.mineap.nndd.player.comment.CommentManager;
59 import org.mineap.nndd.player.comment.Comments;
60 import org.mineap.nndd.util.DateUtil;
61 import org.mineap.nndd.util.IchibaBuilder;
62 import org.mineap.nndd.util.LibraryUtil;
63 import org.mineap.nndd.util.NumberUtil;
64 import org.mineap.nndd.util.PathMaker;
65 import org.mineap.nndd.util.RelationTypeUtil;
66 import org.mineap.nndd.util.ThumbInfoAnalyzer;
67 import org.mineap.nndd.util.ThumbInfoUtil;
68 import org.mineap.nndd.util.WebServiceAccessUtil;
69 import org.mineap.util.config.ConfigIO;
70 import org.mineap.util.config.ConfigManager;
71 import org.osmf.events.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 * VideoDisplay���������������������������������������������������������
1459 * @param videoDisplay
1460 *
1461 */
1462 private function addVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1463 videoDisplay.addEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1464 videoDisplay.addEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1465 videoDisplay.addEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1466 }
1467
1468 /**
1469 * VideoDisplay���������������������������������������������������������
1470 * @param videoDisplay
1471 *
1472 */
1473 private function removeVideoDisplayEventListeners(videoDisplay:VideoDisplay):void{
1474 if(videoDisplay.hasEventListener(TimeEvent.CURRENT_TIME_CHANGE)){
1475 videoDisplay.removeEventListener(TimeEvent.CURRENT_TIME_CHANGE, currentTimeChangeEventHandler);
1476 }
1477 if(videoDisplay.hasEventListener(TimeEvent.DURATION_CHANGE)){
1478 videoDisplay.removeEventListener(TimeEvent.DURATION_CHANGE, durationChangeEventHandler);
1479 }
1480 if(videoDisplay.hasEventListener(VideoEvent.COMPLETE)){
1481 videoDisplay.removeEventListener(TimeEvent.COMPLETE, videoDisplayCompleteHandler);
1482 }
1483 }
1484
1485 /**
1486 *
1487 * @param event
1488 *
1489 */
1490 private function durationChangeEventHandler(event:TimeEvent):void{
1491 if(videoInfoView.isResizePlayerEachPlay){
1492 resizePlayerJustVideoSize(videoPlayer.nowRatio);
1493 }else{
1494 resizePlayerJustVideoSize();
1495 }
1496 }
1497
1498 /**
1499 *
1500 * @param loader
1501 *
1502 */
1503 // private function removeMovieClipEventHandlers(loader:Loader):void{
1504 // if(loader.hasEventListener(Event.COMPLETE)){
1505 // loader.removeEventListener(Event.COMPLETE, convertCompleteHandler);
1506 // }
1507 // }
1508
1509 /**
1510 * ������������������������������������������������������������������������������
1511 * @return
1512 *
1513 */
1514 public function getStreamingProgress():int{
1515 var value:int = 0;
1516 if(isStreamingPlay){
1517 if(videoDisplay != null){
1518 value = (videoDisplay.bytesLoaded*100 / videoDisplay.bytesTotal);
1519 }else if(loader != null && loader.contentLoaderInfo != null){
1520 value = (loader.contentLoaderInfo.bytesLoaded*100 / loader.contentLoaderInfo.bytesTotal);
1521 }else{
1522 value = 100;
1523 }
1524 }else{
1525 value = 100;
1526 }
1527 return value;
1528 }
1529
1530 /**
1531 *
1532 * @return
1533 *
1534 */
1535 public function get bytesLoaded():Number{
1536
1537 var value:Number = 0.0;
1538
1539 if(videoDisplay != null){
1540 value = videoDisplay.bytesLoaded;
1541 }else if(loader != null && loader.contentLoaderInfo != null){
1542 value = loader.contentLoaderInfo.bytesLoaded;
1543 }
1544
1545 return value;
1546 }
1547
1548 /**
1549 *
1550 * @param event
1551 *
1552 */
1553 private function streamingProgressHandler(event:TimerEvent):void{
1554 if(isStreamingPlay){
1555 var value:int = getStreamingProgress();
1556 if(value >= 100){
1557 this.videoPlayer.label_playSourceStatus.text = "Streaming:100%";
1558 streamingProgressCount = 0;
1559 videoPlayer.videoController.resetStatusAlpha();
1560 if(streamingProgressTimer != null){
1561 streamingProgressTimer.stop();
1562 }
1563
1564 // 100%���������������������������������������������������������������������������������������
1565 if(this.bytesLoaded <= 64){
1566 if(this.streamingRetryCount <= 3 ){
1567 // ���������������
1568 this.streamingRetryCount++;
1569 stop();
1570 logManager.addLog("���������������������������������������(���������������������������:������������������������������:" + this.bytesLoaded + ")");
1571 videoPlayer.label_downloadStatus.text = "������������������������������������������������������������������(" + this.streamingRetryCount +"������ )";
1572
1573 if(nicoVideoAccessRetryTimer != null){
1574 nicoVideoAccessRetryTimer.stop();
1575 nicoVideoAccessRetryTimer = null;
1576 }
1577 nicoVideoAccessRetryTimer = new Timer(1000*this.streamingRetryCount, 1);
1578 nicoVideoAccessRetryTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
1579 (event.currentTarget as Timer).stop();
1580 play();
1581 });
1582 nicoVideoAccessRetryTimer.start();
1583
1584 }else{
1585 stop();
1586 logManager.addLog("���������������������������:������������������������������:" + this.bytesLoaded);
1587 videoPlayer.label_downloadStatus.text = "���������������������������������������������(���������������������������������������������������)";
1588 }
1589 }else{
1590 // ������������������
1591 this.streamingRetryCount = 0;
1592 }
1593
1594 }else{
1595
1596 var str:String = " ";
1597 if(streamingProgressCount <= 10){
1598 str = ". ";
1599 }else if(streamingProgressCount > 10 && streamingProgressCount <= 20){
1600 str = ".. ";
1601 }else if(streamingProgressCount > 20 && streamingProgressCount <= 30){
1602 str = "...";
1603 }
1604
1605 this.videoPlayer.label_playSourceStatus.text = "Streaming:" + value + "%" + str;
1606 if(streamingProgressCount >= 30){
1607 streamingProgressCount = 0;
1608 }else{
1609 streamingProgressCount = streamingProgressCount + 2;
1610 }
1611 }
1612 }else{
1613 if(streamingProgressTimer != null){
1614 streamingProgressTimer.stop();
1615 }
1616 }
1617 }
1618
1619 /**
1620 * ������������������������������������������������������
1621 * @param evt
1622 *
1623 */
1624 private function currentTimeChangeEventHandler(event:TimeEvent = null):void{
1625 try{
1626 var allSec:String="00",allMin:String="0";
1627 var nowSec:String="00",nowMin:String="0";
1628
1629 this.commentTimerVpos = event.time*1000;
1630
1631 nowSec = String(int(this.videoDisplay.currentTime%60));
1632 nowMin = String(int(this.videoDisplay.currentTime/60));
1633
1634 allSec = String(int(this.videoDisplay.duration%60));
1635 allMin = String(int(this.videoDisplay.duration/60));
1636
1637 if(nowSec.length == 1){
1638 nowSec = "0" + nowSec;
1639 }
1640 if(allSec.length == 1){
1641 allSec = "0" + allSec;
1642 }
1643
1644 videoPlayer.videoController_under.slider_timeline.enabled = true;
1645 videoPlayer.videoController_under.slider_timeline.minimum = 0;
1646 videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1647 if(!this.sliderChanging){
1648
1649 this.videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1650 this.videoPlayer.videoController_under.slider_timeline.maximum = videoDisplay.duration;
1651 videoPlayer.videoController_under.slider_timeline.value = videoDisplay.currentTime;
1652
1653 }
1654 videoPlayer.videoController_under.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1655 videoPlayer.videoController_under.slider_timeline.enabled = true;
1656
1657 videoPlayer.videoController.slider_timeline.enabled = true;
1658 videoPlayer.videoController.slider_timeline.minimum = 0;
1659 videoPlayer.videoController.slider_timeline.maximum = videoDisplay.duration;
1660 if(!this.sliderChanging){
1661 videoPlayer.videoController.slider_timeline.value = videoDisplay.currentTime;
1662 }
1663 videoPlayer.videoController.label_time.text = nowMin + ":" + nowSec + "/" + allMin + ":" + allSec;
1664 videoPlayer.videoController.slider_timeline.enabled = true;
1665 }catch(error:Error){
1666 VideoDisplay(event.currentTarget).stop();
1667 trace(error.getStackTrace());
1668 }
1669 }
1670
1671 /**
1672 * ������������������������������������������������������������������������
1673 * @param evt
1674 *
1675 */
1676 private function videoDisplayCompleteHandler(evt:TimeEvent = null):void{
1677
1678 if(movieEndTimer != null){
1679 movieEndTimer.stop();
1680 movieEndTimer = null;
1681 }
1682 //���������������������������������������������������������
1683 movieEndTimer = new Timer(2000, 1);
1684 movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, videoPlayCompleteWaitHandler);
1685 movieEndTimer.start();
1686
1687 }
1688
1689 /**
1690 *
1691 *
1692 */
1693 private function videoPlayCompleteWaitHandler(event:TimerEvent):void{
1694 if(!isCounted){
1695 //���������������������
1696 var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
1697 if(videoId != null){
1698 addVideoPlayCount(videoId, true);
1699 }
1700 isCounted = true;
1701 }
1702
1703 logManager.addLog("***���������������***");
1704
1705 if(videoPlayer.isRepeat){
1706 if(isPlayListingPlay){
1707 if(isStreamingPlay){
1708 logManager.addLog("***���������������������(���������������������)***");
1709 this.seek(0);
1710 if(this.videoDisplay != null){
1711 this.videoDisplay.play();
1712 }
1713 }else{
1714 logManager.addLog("***���������������������(������������)***");
1715 this.stop();
1716 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList, playingIndex, this.videoPlayer.title);
1717
1718 }
1719 }else if(isStreamingPlay){
1720 logManager.addLog("***���������������������(���������������������)***");
1721 this.seek(0);
1722 if(this.videoDisplay != null){
1723 this.videoDisplay.play();
1724 }
1725 }else{
1726 logManager.addLog("***���������������������(������������)***");
1727 this.stop();
1728 this.play();
1729 }
1730 }else{
1731 this.stop();
1732 if(isPlayListingPlay){
1733 logManager.addLog("***���������������(������������)***");
1734 var windowType:int = PlayerController.WINDOW_TYPE_FLV;
1735 if(playingIndex >= this.videoInfoView.getPlayList().length-1){
1736 playingIndex = 0;
1737 if(this.videoPlayer.videoInfoView.isRepeatAll()){
1738 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1739 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1740 }
1741 }else{
1742 playingIndex++;
1743 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1744 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1745 }
1746 }
1747 }
1748 }
1749
1750
1751 /**
1752 * SWF������������������������������������������������������������������
1753 *
1754 */
1755 private function movieClipCompleteHandler():void{
1756
1757 this.lastFrame = 0;
1758 this.lastNicowariFrame = 0;
1759
1760 if(movieEndTimer != null){
1761 movieEndTimer.stop();
1762 movieEndTimer = null;
1763 }
1764 //���������������������������������������������������������
1765 movieEndTimer = new Timer(2000, 1);
1766 movieEndTimer.addEventListener(TimerEvent.TIMER_COMPLETE, movieClipPlayCompleteWaitHandler);
1767 movieEndTimer.start();
1768
1769
1770 }
1771
1772 /**
1773 *
1774 *
1775 */
1776 private function movieClipPlayCompleteWaitHandler(event:TimerEvent):void{
1777 if(!isCounted){
1778 //���������������������
1779 var videoId:String = LibraryUtil.getVideoKey(this.source);
1780 if(videoId == null){
1781 //���������������������������������������������������������
1782 videoId = LibraryUtil.getVideoKey(this.videoPlayer.title);
1783 }
1784 if(videoId != null){
1785 addVideoPlayCount(videoId, true);
1786 }
1787 isCounted = true;
1788 }
1789
1790 logManager.addLog("***���������������***");
1791 this.lastFrame = 0;
1792 this.lastNicowariFrame = 0;
1793
1794 if(videoPlayer.isRepeat){
1795 if(isPlayListingPlay){
1796 if(isStreamingPlay){
1797 logManager.addLog("***���������������������(���������������������)***");
1798 this.seek(0);
1799 }else{
1800 logManager.addLog("***���������������������(������������)***");
1801 this.stop();
1802 mc.gotoAndStop(0);
1803 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1804 playingIndex, this.videoPlayer.title);
1805 }
1806 }else if(isStreamingPlay){
1807 logManager.addLog("***���������������������(���������������������)***");
1808 this.seek(0);
1809 }else{
1810 logManager.addLog("***���������������������(������������)***");
1811 this.stop();
1812 mc.gotoAndStop(0);
1813 this.play();
1814 }
1815 }else{
1816 this.stop();
1817 mc.gotoAndStop(0);
1818 if(isPlayListingPlay){
1819 logManager.addLog("***���������������(������������)***");
1820 var windowType:int = PlayerController.WINDOW_TYPE_FLV;
1821 if(playingIndex >= this.videoInfoView.getPlayList().length-1){
1822 playingIndex = 0;
1823 if(this.videoPlayer.videoInfoView.isRepeatAll()){
1824 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1825 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1826 }
1827 }else{
1828 playingIndex++;
1829 playMovie(this.videoInfoView.getPlayListUrl(playingIndex), this.videoInfoView.playList,
1830 playingIndex, PathMaker.getVideoName(this.videoInfoView.getPlayListUrl(playingIndex)));
1831 }
1832 }
1833 }
1834
1835 isMovieClipStopping = false;
1836 }
1837
1838
1839 /**
1840 * ���������������������ID������������������������������������������������������������1���������������
1841 * @param videoId ���������������������������������������������������ID
1842 * @param isSave ���������������������������������������������������
1843 */
1844 private function addVideoPlayCount(videoId:String, isSave:Boolean):void{
1845 var nnddVideo:NNDDVideo = libraryManager.isExist(videoId);
1846 if(nnddVideo != null){
1847 nnddVideo.playCount = nnddVideo.playCount + 1;
1848 libraryManager.update(nnddVideo, isSave);
1849 trace("���������������������:" + nnddVideo.videoName + "," + nnddVideo.playCount);
1850 }else{
1851 //���������������
1852 trace("������������������������������������:" + videoId);
1853 }
1854 }
1855
1856 /**
1857 * ���������������������������������������������
1858 * swf���������������SWF���������������������������������������������������
1859 *
1860 * @param event
1861 *
1862 */
1863 private function commentTimerHandler(event:TimerEvent):void{
1864
1865 if(isPlayerClosing){
1866 if(commentTimer != null){
1867 commentTimer.stop();
1868 commentTimer.reset();
1869 }
1870 return;
1871 }
1872
1873 // ���������������
1874 this.setVolume(this.videoPlayer.videoController.slider_volume.value);
1875
1876 var nowSec:String="00",nowMin:String="0";
1877 nowSec = String(int(commentTimerVpos/1000%60));
1878 nowMin = String(int(commentTimerVpos/1000/60));
1879 if(nowSec.length == 1){
1880 nowSec = "0" + nowSec;
1881 }
1882 var nowTime:String = nowMin + ":" + nowSec;
1883
1884 var allSec:String="00",allMin:String="0"
1885 if(this.windowType==PlayerController.WINDOW_TYPE_SWF && this.mc != null){
1886 allSec = String(int(mc.totalFrames/swfFrameRate%60));
1887 allMin = String(int(mc.totalFrames/swfFrameRate/60));
1888 }else if(this.windowType==PlayerController.WINDOW_TYPE_FLV && this.videoDisplay != null){
1889 allSec = String(int(videoDisplay.duration%60));
1890 allMin = String(int(videoDisplay.duration/60));
1891 }
1892 if(allSec.length == 1){
1893 allSec = "0" + allSec;
1894 }
1895 var allTime:String = allMin +":" + allSec;
1896
1897 if(!isCounted && commentTimerVpos > 10000){
1898 //���������������������
1899 var videoId:String = LibraryUtil.getVideoKey(this.videoPlayer.title);
1900 if(videoId != null){
1901 addVideoPlayCount(videoId, false);
1902 }
1903 isCounted = true;
1904 }
1905
1906 //SWF���������������������������������������������������������������������
1907 if(isMovieClipPlaying && this.windowType==PlayerController.WINDOW_TYPE_SWF && this.mc != null){
1908
1909 videoPlayer.videoController_under.slider_timeline.enabled = true;
1910 videoPlayer.videoController_under.slider_timeline.minimum = 0;
1911 videoPlayer.videoController_under.slider_timeline.maximum = mc.totalFrames;
1912
1913 videoPlayer.videoController.slider_timeline.enabled = true;
1914 videoPlayer.videoController.slider_timeline.minimum = 0;
1915 videoPlayer.videoController.slider_timeline.maximum = mc.totalFrames;
1916
1917 if(!this.sliderChanging){
1918 videoPlayer.videoController_under.slider_timeline.value = mc.currentFrame;
1919 videoPlayer.videoController.slider_timeline.value = mc.currentFrame;
1920 }
1921
1922 // trace(nowMin + "/" + nowSec);
1923
1924 videoPlayer.videoController_under.label_time.text = nowTime + "/"+ allTime;
1925 videoPlayer.videoController.label_time.text = nowTime + "/"+ allTime;
1926
1927 if(mc.currentFrame >= mc.totalFrames-1 || mc.currentFrame == this.lastFrame ){
1928 this.lastFrame = mc.currentFrame;
1929 //���������movieClip������������������������������������������������������
1930 if(!isMovieClipStopping){
1931 isMovieClipStopping = true;
1932 movieClipCompleteHandler();
1933 }
1934 return;
1935 }else{
1936 if(!isMovieClipStopping){
1937 this.lastFrame = mc.currentFrame;
1938 }
1939 }
1940 }
1941
1942 var tempTime:Number = (new Date).time;
1943
1944 //SWF������������������������������������������������������������������
1945 if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
1946 this.commentTimerVpos += (tempTime - this.time);
1947 }
1948
1949 //���������������������
1950 var commentArray:Vector.<NNDDComment> = this.commentManager.setComment(commentTimerVpos, (tempTime - this.time)*3, this.videoPlayer.isShowComment);
1951 this.commentManager.moveComment(tempTime/1000 - this.time/1000, videoInfoView.showCommentSec);
1952 this.commentManager.removeComment(commentTimerVpos, videoInfoView.showCommentSec * 1000);
1953 this.time = tempTime;
1954
1955 //������������������������������������������������������
1956 if(videoPlayer.videoInfoView.checkbox_SyncComment.selected && videoPlayer.videoInfoView.visible
1957 // && (videoPlayer.stage.displayState != StageDisplayState.FULL_SCREEN_INTERACTIVE
1958 // && videoInfoView.isActive)
1959 ){
1960
1961 var lastMin:String = commentManager.getComments().lastMin;
1962
1963 var tempNowTime:String = nowTime;
1964 if(lastMin.length == 3){
1965 //���������������3���������������:���������������������
1966 if(tempNowTime.length == 4){
1967 //���������������:������������4���
1968 tempNowTime = "00" + tempNowTime;
1969 }else if(tempNowTime.length == 5){
1970 //���������������:������������5���
1971 tempNowTime = "0" + tempNowTime;
1972 }
1973 }else if(lastMin.length == 2){
1974 //���������������2���������������:������������5������
1975 if(tempNowTime.length == 4){
1976 //���������������:������������4���
1977 tempNowTime = "0" + tempNowTime;
1978 }
1979
1980 }else if(lastMin.length == 1){
1981 //���������������1���������������:������������4������
1982
1983 }
1984
1985 if(tempNowTime.length > lastMin.length+3){
1986 tempNowTime = tempNowTime.substring(1);
1987 }
1988
1989
1990 var index:int = 0;
1991 if(commentArray.length > 0 && comments != null){
1992 var myComment:NNDDComment = commentArray[0];
1993 for each(var comment:NNDDComment in commentArray){
1994 if(comment.vpos > myComment.vpos){
1995 myComment = comment;
1996 }
1997 }
1998 index = comments.getCommentIndex(tempNowTime, myComment.text);
1999
2000 if(this.videoPlayer.videoInfoView.tabNavigator_comment.selectedIndex == 0){
2001
2002 if(this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition < index){
2003 index = index - (this.videoPlayer.videoInfoView.dataGrid_comment.rowCount) + 2;
2004 if(index > 0){
2005 if(index < this.videoPlayer.videoInfoView.dataGrid_comment.maxVerticalScrollPosition){
2006 this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = index;
2007 }else{
2008 this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = this.videoPlayer.videoInfoView.dataGrid_comment.maxVerticalScrollPosition;
2009 }
2010 }
2011 }
2012
2013 }else if(this.videoPlayer.videoInfoView.tabNavigator_comment.selectedIndex == 1){
2014
2015 if(this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition < index){
2016 index = index - (this.videoPlayer.videoInfoView.dataGrid_oldComment.rowCount) + 2;
2017 if(index > 0){
2018 if(index < this.videoPlayer.videoInfoView.dataGrid_oldComment.maxVerticalScrollPosition){
2019 this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition = index;
2020 }else{
2021 this.videoPlayer.videoInfoView.dataGrid_oldComment.verticalScrollPosition = this.videoPlayer.videoInfoView.dataGrid_oldComment.maxVerticalScrollPosition;
2022 }
2023 }
2024 }
2025
2026 }
2027
2028 }
2029 }
2030
2031
2032 //������������������������
2033 var date:Date = new Date();
2034 var hh:String = new String(int(date.getHours()));
2035 var mm:String = new String(int(date.getMinutes()));
2036 if(hh.length == 1){
2037 hh = "0" + hh;
2038 }
2039 if(mm.length == 1){
2040 mm = "0" + mm;
2041 }
2042 var jihouResult:Array = commentManager.isJihouSettingTime(hh + mm);
2043 if(jihouResult != null && playingJihou == null){
2044 //������������
2045 playingJihou = hh+mm;
2046 playNicowari(jihouResult[0], jihouResult[1]);
2047 }
2048 if(playingJihou != null && playingJihou != (hh+mm)){
2049 playingJihou = null;
2050 }
2051
2052 if(!this.videoPlayer.isShowComment){
2053 this.commentManager.removeAll();
2054 }
2055
2056 }
2057
2058 /**
2059 * ������������������������������������������������������������������������
2060 * @param volume 0������1���������������������������������������������
2061 * @return ������������������������������������
2062 *
2063 */
2064 public function setVolume(volume:Number):Number{
2065 if(this.windowReady){
2066 if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
2067 if(videoDisplay != null){
2068 videoDisplay.volume = volume;
2069 this.videoPlayer.videoController.slider_volume.value = volume;
2070 this.videoPlayer.videoController_under.slider_volume.value = volume;
2071 return videoDisplay.volume;
2072 }
2073 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
2074 if(mc != null){
2075 var transForm:SoundTransform = new SoundTransform(volume, 0);
2076 mc.soundTransform = transForm;
2077 this.videoPlayer.videoController.slider_volume.value = volume;
2078 this.videoPlayer.videoController_under.slider_volume.value = volume;
2079 return mc.soundTransform.volume;
2080 }
2081 }
2082 }
2083 return 0;
2084 }
2085
2086 /**
2087 * PlayerController���������������CommentManager������������������
2088 * @return
2089 *
2090 */
2091 public function getCommentManager():CommentManager{
2092 return commentManager;
2093 }
2094
2095 /**
2096 * ���������������������������������������������������������������������������������������������������
2097 * ���������SWF������������������������������������������������������������������������Loader������������������������������������������������������
2098 */
2099 public function windowResized(isCommentRemove:Boolean = true):void{
2100
2101 if(this.windowReady){
2102
2103 //SWFLoader���������������������������������������
2104 if(swfLoader != null && this.windowType == PlayerController.WINDOW_TYPE_SWF){
2105 //������������������
2106
2107 (swfLoader.getChildAt(0) as Loader).x = 0;
2108 (swfLoader.getChildAt(0) as Loader).y = 0;
2109 var flashDistX:int = (swfLoader.getChildAt(0) as Loader).width - PlayerController.NICO_SWF_WIDTH;
2110 var flashDistY:int = (swfLoader.getChildAt(0) as Loader).height - PlayerController.NICO_SWF_HEIGHT;
2111 var scaleX:Number = swfLoader.width / ((swfLoader.getChildAt(0) as Loader).width - flashDistX);
2112 var scaleY:Number = swfLoader.height / ((swfLoader.getChildAt(0) as Loader).height - flashDistY);
2113 if(scaleX < scaleY){
2114 (swfLoader.getChildAt(0) as Loader).scaleX = scaleX;
2115 (swfLoader.getChildAt(0) as Loader).scaleY = scaleX;
2116 var centorY:int = swfLoader.height / 2;
2117 var newY:int = centorY - (PlayerController.NICO_SWF_HEIGHT*scaleX)/2;
2118 // trace("newY:"+newY);
2119 if(newY > 0){
2120 (swfLoader.getChildAt(0) as Loader).y = newY;
2121 }
2122 }else{
2123 (swfLoader.getChildAt(0) as Loader).scaleX = scaleY;
2124 (swfLoader.getChildAt(0) as Loader).scaleY = scaleY;
2125 var centorX:int = swfLoader.width / 2;
2126 var newX:int = centorX - (PlayerController.NICO_SWF_WIDTH*scaleY)/2;
2127 // trace("newX:"+newX);
2128 if(newX > 0){
2129 (swfLoader.getChildAt(0) as Loader).x = newX;
2130 }
2131 }
2132
2133 }
2134
2135 //���������SWF������������������������������������������
2136 if(nicowariSwfLoader != null){
2137
2138 (nicowariSwfLoader.getChildAt(0) as Loader).x = 0;
2139 (nicowariSwfLoader.getChildAt(0) as Loader).y = 0;
2140
2141 var nicowariDistX:Number = (nicowariSwfLoader.getChildAt(0) as Loader).width - PlayerController.NICO_WARI_WIDTH;
2142 var nicowariDistY:Number = (nicowariSwfLoader.getChildAt(0) as Loader).height - PlayerController.NICO_WARI_HEIGHT;
2143
2144 var nicowariScaleX:Number = nicowariSwfLoader.width / ((nicowariSwfLoader.getChildAt(0) as Loader).width - nicowariDistX);
2145 var nicowariScaleY:Number = nicowariSwfLoader.height / ((nicowariSwfLoader.getChildAt(0) as Loader).height - nicowariDistY);
2146 if(nicowariScaleX < nicowariScaleY){
2147 (nicowariSwfLoader.getChildAt(0) as Loader).scaleX = nicowariScaleX;
2148 (nicowariSwfLoader.getChildAt(0) as Loader).scaleY = nicowariScaleX;
2149 centorY = nicowariSwfLoader.height / 2;
2150 newY = centorY - (PlayerController.NICO_WARI_HEIGHT*nicowariScaleX)/2;
2151 // trace("newY:"+newY);
2152 if(newY > 0){
2153 (nicowariSwfLoader.getChildAt(0) as Loader).y = newY;
2154 }
2155 }else{
2156 (nicowariSwfLoader.getChildAt(0) as Loader).scaleX = nicowariScaleY;
2157 (nicowariSwfLoader.getChildAt(0) as Loader).scaleY = nicowariScaleY;
2158 centorX = nicowariSwfLoader.width / 2;
2159 newX = centorX - (PlayerController.NICO_WARI_WIDTH*nicowariScaleY)/2;
2160 // trace("newX:"+newX);
2161 if(newX > 0){
2162 (nicowariSwfLoader.getChildAt(0) as Loader).x = newX;
2163 }
2164 }
2165 }
2166
2167 //���������������������������������
2168 if(isCommentRemove){
2169 commentManager.removeAll();
2170 }
2171 }
2172 }
2173
2174 /**
2175 * ���������������seekTime������������������������������������������������
2176 * @param seekTime ������������������������������������������������������������������������������������������������������
2177 *
2178 */
2179 public function seek(seekTime:Number):void{
2180 trace(seekTime);
2181 if(this.windowReady){
2182 if((new Date().time)-lastSeekTime > 1000){
2183 if((videoDisplay != null && videoDisplay.initialized && videoDisplay.duration > 0) || (swfLoader != null && swfLoader.initialized)){
2184
2185
2186 trace("seekStart:" + seekTime);
2187 this.commentTimer.stop();
2188 this.commentTimer.reset();
2189
2190 //������������������������������������������������������
2191 commentManager.getComments().resetEnableShowFlag();
2192
2193 //���������������������������������������������
2194 this.videoPlayer.videoInfoView.dataGrid_comment.verticalScrollPosition = 0;
2195
2196 if(this.windowType == PlayerController.WINDOW_TYPE_FLV){
2197 videoDisplay.seek(seekTime);
2198 commentTimerVpos = seekTime*1000;
2199 }else if(this.windowType == PlayerController.WINDOW_TYPE_SWF){
2200 mc.gotoAndPlay(int(seekTime));
2201 commentTimerVpos = (seekTime/swfFrameRate)*1000;
2202 }
2203
2204 commentManager.removeAll();
2205
2206 if(!this.pausing || this.windowType == PlayerController.WINDOW_TYPE_SWF){
2207 commentTimer.start();
2208 }
2209 lastSeekTime = new Date().time;
2210
2211
2212
2213 }
2214 }
2215 }
2216 }
2217
2218
2219 /**
2220 * ������Player������������������������������������������������
2221 * @return Player���������������������������true������������������������������false���
2222 *
2223 */
2224 public function isOpen():Boolean{
2225 if(this.videoPlayer.nativeWindow != null){
2226 return !this.videoPlayer.closed;
2227 }
2228 return false;
2229 }
2230
2231 /**
2232 * Player������������������Open������������
2233 *
2234 */
2235 public function open():Boolean{
2236 if(this.videoPlayer != null){
2237 this.videoPlayer.open();
2238 }else{
2239 return false;
2240 }
2241 if(this.videoInfoView != null){
2242 this.videoInfoView.open();
2243 }else{
2244 return false;
2245 }
2246 return true;
2247 }
2248
2249 /**
2250 * ���������������������Player������������������������������
2251 *
2252 */
2253 public function playerExit():void{
2254
2255 this.stop();
2256 if(this.videoPlayer != null && this.videoPlayer.nativeWindow != null && !this.videoPlayer.closed){
2257 this.videoPlayer.restore();
2258 // this.videoPlayer.saveStore();
2259 this.videoPlayer.close();
2260 }
2261 if(this.videoPlayer != null && this.videoInfoView.nativeWindow != null && !this.videoInfoView.closed){
2262 this.saveNgList();
2263 this.videoInfoView.restore();
2264 // this.videoInfoView.saveStore();
2265 this.videoInfoView.close();
2266 }
2267 }
2268
2269 /**
2270 * ���������NG���������������������������������
2271 *
2272 */
2273 public function saveNgList():void{
2274 this.ngListManager.saveNgList(LibraryManagerBuilder.instance.libraryManager.systemFileDir);
2275 }
2276
2277 public function getCommentListProvider():ArrayCollection{
2278 return this.videoPlayer.getCommentListProvider();
2279 }
2280
2281 public function getOwnerCommentListProvider():ArrayCollection{
2282 return this.videoPlayer.videoInfoView.ownerCommentProvider;
2283 }
2284
2285
2286 /**
2287 * ������������������NG���������������������������������������������������
2288 * @param date ������������������������������������
2289 */
2290 public function reloadLocalComment(date:Date = null):void{
2291
2292 if(date != null){
2293 trace(date.time);
2294 }
2295
2296 if(this.videoInfoView.ngListProvider != null){
2297 if(!this.isStreamingPlay && this.source != null && this.source != "" ){
2298 comments = new Comments(PathMaker.createNomalCommentPathByVideoPath(source),
2299 PathMaker.createOwnerCommentPathByVideoPath(source), videoPlayer.getCommentListProvider(),
2300 this.videoPlayer.videoInfoView.ownerCommentProvider, this.ngListManager,
2301 this.videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
2302 this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable, date);
2303 }else if(this.isStreamingPlay){
2304 comments = new Comments(PathMaker.createNomalCommentPathByVideoPath(LibraryManagerBuilder.instance.libraryManager.tempDir.url + "/nndd.flv"),
2305 PathMaker.createOwnerCommentPathByVideoPath(LibraryManagerBuilder.instance.libraryManager.tempDir.url + "/nndd.flv"),
2306 this.videoPlayer.getCommentListProvider(), this.videoPlayer.videoInfoView.ownerCommentProvider,
2307 this.ngListManager, videoInfoView.isShowOnlyPermissionComment, this.videoInfoView.isHideSekaShinComment,
2308 this.videoInfoView.showCommentCount, this.videoInfoView.isNgUpEnable, date);
2309 }
2310 commentManager.setComments(comments);
2311 }
2312 this.windowResized();
2313
2314 }
2315
2316 /**
2317 * ���������������������������������������������������������������
2318 * @param videoPath
2319 *
2320 */
2321 private function setInfo(videoPath:String, thumbInfoPath:String, ichibaInfoPath:String, isStreaming:Boolean):void{
2322
2323 var videoID:String = PathMaker.getVideoID(videoPath);
2324
2325 if(!isStreaming){ //������������������������������������������������������������������������������������������������������������������������������
2326
2327 if(videoID != null && (mailAddress != null && password != null) && (mailAddress != "" && password != "") ){
2328
2329 //���������
2330 videoInfoView.ichibaNicoProvider.addItem({
2331 col_image:"",
2332 col_info:"������������������������������",
2333 col_link:""
2334 });
2335 videoPlayer.videoInfoView.owner_text_nico = "";
2336
2337 }else{
2338 videoInfoView.ichibaNicoProvider.addItem({
2339 col_image:"",
2340 col_info:"������������������������������������������������",
2341 col_link:""
2342 });
2343
2344 var thumbInfoAnalyzer:ThumbInfoAnalyzer = null;
2345
2346 if(videoPath != null){
2347
2348 var thumbInfoPath:String = PathMaker.createThmbInfoPathByVideoPath(videoPath);
2349
2350 var fileIO:FileIO = new FileIO(logManager);
2351 var xml:XML = fileIO.loadXMLSync(thumbInfoPath, false);
2352
2353 if(xml != null){
2354 thumbInfoAnalyzer = new ThumbInfoAnalyzer(xml);
2355 }
2356 }
2357
2358 if(thumbInfoAnalyzer != null){
2359
2360 var dateString:String = "(������������������������������)";
2361 var ownerText:String = "(������������������������������������)";
2362 var htmlInfo:String = "";
2363
2364 if(thumbInfoAnalyzer != null){
2365 var dateFormatter:DateFormatter = new DateFormatter();
2366 dateFormatter.formatString = "YYYY/MM/DD JJ:NN:SS";
2367 var date:Date = thumbInfoAnalyzer.getDateByFirst_retrieve();
2368 dateString = "���������:(������������������������)";
2369 if(date != null){
2370 dateString = "���������:" + dateFormatter.format(date);
2371 }
2372 htmlInfo = thumbInfoAnalyzer.htmlTitle + "<br />" + dateString + "<br />" + thumbInfoAnalyzer.playCountAndCommentCountAndMyListCount;
2373
2374 ownerText = thumbInfoAnalyzer.thumbInfoHtml + "\n(���������������������������������)";
2375 }else{
2376
2377 if(videoPlayer.videoInfoView.owner_text_local.length > 1){
2378 ownerText = videoPlayer.videoInfoView.owner_text_local + "\n(���������������������������������)";
2379 }
2380
2381 htmlInfo = "(������������������������������)<br />" + dateString + "<br />(���������������������������������)";
2382 }
2383
2384 videoPlayer.videoInfoView.text_info.htmlText = htmlInfo;
2385
2386 if(videoPlayer.videoInfoView.checkbox_showHtml.selected){
2387 videoPlayer.videoInfoView.owner_text_temp = videoPlayer.videoInfoView.owner_text_nico;
2388 videoPlayer.videoInfoView.owner_text_nico = ownerText;
2389 }else{
2390 videoPlayer.videoInfoView.owner_text_temp = ownerText;
2391 }
2392
2393 videoPlayer.videoInfoView.nicoTagProvider = thumbInfoAnalyzer.tagArray;
2394 videoPlayer.videoInfoView.nicoTagProvider.push("(���������������������������������������������������������������)");
2395 videoPlayer.setTagArray(videoPlayer.videoInfoView.nicoTagProvider);
2396
2397 }else{
2398
2399 videoPlayer.videoInfoView.text_info.htmlText = "(������������������������������)<br />(������������������������������)<br />(���������������������������������)";
2400 videoPlayer.videoInfoView.owner_text_nico = "(������������������������������)";
2401
2402 videoPlayer.videoInfoView.nicoTagProvider = videoPlayer.videoInfoView.localTagProvider;
2403 videoPlayer.videoInfoView.nicoTagProvider.push("(���������������������������������������������������������������)");
2404 videoPlayer.setTagArray(videoPlayer.videoInfoView.nicoTagProvider);
2405
2406 }
2407 }
2408 }
2409
2410 if(videoID != null && (mailAddress != null && password != null) && (mailAddress != "" && password != "") ){
2411 retryCount = 0;
2412 setNicoVideoPageInfo(PathMaker.getVideoID(videoID), 0, isStreaming); //���������������������������������������������������
2413 }
2414
2415 setNicoRelationInfo(videoID); //������������������������������������������������������������������������������
2416
2417 setLocalIchibaInfo(ichibaInfoPath, isStreaming);
2418 setLocalThumbInfo(videoID, thumbInfoPath, isStreaming);
2419
2420 }
2421
2422
2423
2424 //-------------------------------------------------------
2425
2426 /**
2427 * ������������������������������������
2428 *
2429 */
2430 public function setNicoRelationInfoForRelationSortTypeChange():void{
2431 var videoId:String = PathMaker.getVideoID(videoPlayer.title);
2432 if(videoId != null){
2433 setNicoRelationInfo(videoId);
2434 }
2435 }
2436
2437 /**
2438 * ������������������������������������������������������������������������
2439 * @param videoID
2440 *
2441 */
2442 private function setNicoRelationInfo(videoID:String):void{
2443
2444 (videoInfoView.relationDataProvider as ArrayCollection).removeAll();
2445
2446 if(videoInfoView == null){
2447 return;
2448 }
2449
2450 if(nicoRelationInfoLoader != null){
2451 try{
2452 nicoRelationInfoLoader.close();
2453 }catch(error:Error){
2454 }
2455 }
2456
2457 videoInfoView.setRelationComboboxEnable(false);
2458
2459 var sort:String = RelationTypeUtil.convertRelationSortType(videoInfoView.relationSortIndex);
2460 var order:String = RelationTypeUtil.convertRelationOrderType(videoInfoView.relationOrderIndex);
2461
2462 logManager.addLog("���������������������������������(videoId:" + videoID + ", sort:" + sort + ", order:" + order + ")");
2463
2464 nicoRelationInfoLoader = new ApiGetRelation();
2465 nicoRelationInfoLoader.addEventListener(Event.COMPLETE, function(event:Event):void{
2466 (videoInfoView.relationDataProvider as ArrayCollection).removeAll();
2467 var analyzer:GetRelationResultAnalyzer = new GetRelationResultAnalyzer();
2468 analyzer.analyze(event.currentTarget.data);
2469 try{
2470 event.currentTarget.close();
2471 }catch(error:Error){
2472 }
2473
2474 if("ok" == analyzer.status){
2475 for each(var item:RelationResultItem in analyzer.videos){
2476 var info:String = HtmlUtil.convertSpecialCharacterNotIncludedString(item.title) + "\n" +
2477 "\t������������:" + NumberUtil.addComma(String(item.view)) + "\n" +
2478 "\t���������������:" + NumberUtil.addComma(String(item.mylist)) + ", ���������������:" + NumberUtil.addComma(String(item.comment)) + "\n" +
2479 "\t���������:" + DateUtil.getDateString(new Date(item.time * 1000));
2480 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2481 col_image:item.thumbnail,
2482 col_info:info,
2483 col_link:item.url
2484 });
2485 }
2486 if(videoInfoView.datagrid_relation != null){
2487 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2488 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2489 }
2490 logManager.addLog("���������������������������������:" + event);
2491 videoInfoView.setRelationComboboxEnable(true);
2492
2493 }else{
2494 logManager.addLog("���������������������������������:status=" + analyzer.status + "," + event);
2495 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2496 col_image:"",
2497 col_info:"������������������������������������(status=" + analyzer.status + ")",
2498 col_link:null
2499 });
2500 if(videoInfoView.datagrid_relation != null){
2501 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2502 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2503 }
2504 videoInfoView.setRelationComboboxEnable(true);
2505 }
2506
2507 });
2508 nicoRelationInfoLoader.addEventListener(HTTPStatusEvent.HTTP_RESPONSE_STATUS, function(event:HTTPStatusEvent):void{
2509 logManager.addLog("\t" + event.toString());
2510 });
2511 nicoRelationInfoLoader.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void{
2512 (videoInfoView.relationDataProvider as ArrayCollection).removeAll();
2513 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2514 col_image:"",
2515 col_info:"������������������������������������(���������������)",
2516 col_link:null
2517 });
2518 logManager.addLog("������������������������������������:" + event);
2519 try{
2520 event.currentTarget.close();
2521 }catch(error:Error){
2522 trace(error.getStackTrace());
2523 }
2524 if(videoInfoView.datagrid_relation != null){
2525 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2526 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2527 }
2528 videoInfoView.setRelationComboboxEnable(true);
2529 });
2530 nicoRelationInfoLoader.getRelation(videoID, 1, sort, order);
2531
2532 (videoInfoView.relationDataProvider as ArrayCollection).addItem({
2533 col_image:"",
2534 col_info:"������������������������������������������...",
2535 col_link:null
2536 });
2537 if(videoInfoView.datagrid_relation != null){
2538 (videoInfoView.datagrid_relation as DataGrid).validateDisplayList();
2539 (videoInfoView.datagrid_relation as DataGrid).validateNow();
2540 }
2541
2542 }
2543
2544 /**
2545 * ������������������������������������������
2546 */
2547 private var retryCount:int = 0;
2548
2549 /**
2550 * ���������������������������������������������������������������������������������������������������������<br />
2551 * ���������������������
2552 * ������������������������������������������
2553 * ������������������������
2554 * ���������������
2555 * ������������������
2556 *
2557 * @param videoId
2558 * @param delay
2559 *
2560 */
2561 private function setNicoVideoPageInfo(videoId:String, delay:int, onlyOwnerText:Boolean = false):void{
2562
2563 if(retryCount > 5){
2564 trace("setNicoVideoPageInfo���������������������������");
2565 logManager.addLog("���������������������������������������������(������������������������):" + _videoID);
2566 return;
2567 }else{
2568 logManager.addLog("������������������������������������������(������������:" + retryCount + "):" + _videoID);
2569 }
2570 retryCount++;
2571
2572 if(delay == 0){
2573 getInfo(onlyOwnerText);
2574 }else{
2575 if(nicoVideoPageGetRetryTimer != null){
2576 nicoVideoPageGetRetryTimer.stop();
2577 nicoVideoPageGetRetryTimer = null;
2578 }
2579
2580 nicoVideoPageGetRetryTimer = new Timer(delay, 1);
2581 nicoVideoPageGetRetryTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function(event:Event):void{
2582 trace("getInfo���������������:" + retryCount + "���");
2583 (event.currentTarget as Timer).stop();
2584 getInfo(onlyOwnerText);
2585 });
2586 nicoVideoPageGetRetryTimer.start();
2587 }
2588
2589 function getInfo(onlyOwnerText:Boolean):void{
2590 var watchVideoPage:NNDDVideoPageWatcher = new NNDDVideoPageWatcher();
2591 watchVideoPage.addEventListener(NNDDVideoPageWatcher.SUCCESS, function(event:Event):void{
2592
2593 try{
2594 var fail:Boolean = false;
2595
2596 var description:String = watchVideoPage.watcher.getDescription();
2597 if(description != null && description.length > 0 ){
2598
2599 // videoPlayer.videoInfoView.owner_text_nico = ThumbInfoUtil.encodeThumbInfo(description);
2600
2601 if(videoPlayer.videoInfoView.checkbox_showHtml.selected){
2602 videoPlayer.videoInfoView.owner_text_temp = videoPlayer.videoInfoView.owner_text_nico;
2603 videoPlayer.videoInfoView.owner_text_nico = ThumbInfoUtil.encodeThumbInfo(description);
2604 }else{
2605 videoPlayer.videoInfoView.owner_text_temp = ThumbInfoUtil.encodeThumbInfo(description);
2606 }
2607
2608 }else{
2609 fail = true;
2610 }
2611
2612 if(!watchVideoPage.onlyOwnerText){
2613 var thumbInfo:String = watchVideoPage.thumbInfoLoader.thumbInfo;
2614 if(thumbInfo != null){
2615 var analyzer:ThumbInfoAnalyzer = new ThumbInfoAnalyzer(new XML(thumbInfo));
2616 if(analyzer.errorCode != null && analyzer.errorCode.length > 0 && !isStreamingPlay){
2617 // ���������������������������������������������������������������������������������������
2618 var video:NNDDVideo = libraryManager.isExist(videoId);
2619 var thumbInfoPath:String = PathMaker.createThmbInfoPathByVideoPath(video.getDecodeUrl());
2620 var fileIO:FileIO = new FileIO();
2621 var xml:XML = fileIO.loadXMLSync(thumbInfoPath, false);
2622 analyzer = new ThumbInfoAnalyzer(xml);
2623 setNicoThumbInfo(analyzer);
2624 }
2625 setNicoThumbInfo(analyzer);
2626
2627 }else{
2628 fail = true;
2629 }
2630
2631 var ichibaInfo:Object = watchVideoPage.ichibaInfoLoader.data;
2632 if(ichibaInfo != null && ichibaInfo is String){
2633 var ichibaBuilder:IchibaBuilder = new IchibaBuilder(logManager);
2634 videoInfoView.ichibaNicoProvider = ichibaBuilder.makeIchibaInfo(ichibaInfo as String);
2635 videoInfoView.ichibaNicoProvider.refresh();
2636 }else{
2637 videoInfoView.ichibaNicoProvider.addItem({
2638 col_image:"",
2639 col_info:"���������������������������������������������(���������������������)",
2640 col_link:""
2641 });
2642 fail = true;
2643 }
2644 }
2645
2646 }catch(error:Error){
2647 fail = true;
2648 trace(error.getStackTrace());
2649 }
2650
2651 if(fail){
2652 setNicoVideoPageInfo(PathMaker.getVideoID(videoId), 1000*retryCount);
2653 logManager.addLog("���������������������������������������������(���������������������)" + _videoID);
2654 }else{
2655 logManager.addLog("���������������������������������������������:" + _videoID);
2656 }
2657
2658 });
2659 watchVideoPage.addEventListener(NNDDVideoPageWatcher.FAIL, function(event:ErrorEvent):void{
2660 logManager.addLog("���������������������������������������������:" + _videoID + ":" + event.text);
2661 trace("���������������������������������������������:" + _videoID + ":" + event.text);
2662 });
2663 watchVideoPage.watch(mailAddress, password, PathMaker.getVideoID(videoId), onlyOwnerText);
2664 }
2665 }
2666
2667 /**
2668 * ������������������������������������������������Player���������������������������������������������
2669 * @param analyzer
2670 *
2671 */
2672 private function setNicoThumbInfo(analyzer:ThumbInfoAnalyzer):void{
2673
2674 videoPlayer.videoInfoView.nicoTagProvider = analyzer.tagArray;
2675 videoPlayer.setTagArray(analyzer.tagArray);
2676
2677 if(analyzer.tagArray.length == 0 && videoPlayer.videoInfoView.localTagProvider.length > 0){
2678 videoPlayer.videoInfoView.nicoTagProvider = videoPlayer.videoInfoView.localTagProvider;
2679 videoPlayer.videoInfoView.nicoTagProvider.push("(���������������������������������������������������������������)");
2680 videoPlayer.setTagArray(videoPlayer.videoInfoView.nicoTagProvider);
2681 }
2682
2683 var dateString:String = "(������������������������������)";
2684 var ownerText:String = "(������������������������������������)";
2685 var htmlInfo:String = "";
2686
2687 var dateFormatter:DateFormatter = new DateFormatter();
2688 dateFormatter.formatString = "YYYY/MM/DD JJ:NN:SS";
2689 var date:Date = analyzer.getDateByFirst_retrieve();
2690 dateString = "���������:(������������������������)";
2691 if(date != null){
2692 dateString = "���������:" + dateFormatter.format(date);
2693 }
2694 htmlInfo = analyzer.htmlTitle + "<br />" + dateString + "<br />" + analyzer.playCountAndCommentCountAndMyListCount;
2695
2696 ownerText = analyzer.thumbInfoHtml;
2697
2698 videoPlayer.videoInfoView.text_info.htmlText = htmlInfo;
2699
2700 if(videoPlayer.videoInfoView.owner_text_nico.length == 0){
2701 videoPlayer.videoInfoView.owner_text_nico = ownerText;
2702 }
2703 }
2704
2705
2706 /**
2707 * ������������������������������������
2708 * @param ichibaInfoPath
2709 * @param isStreaming true������������������������������������������������������������������������������������������
2710 *
2711 */
2712 private function setLocalIchibaInfo(ichibaInfoPath:String, isStreaming:Boolean):void{
2713
2714 var ichibaBuilder:IchibaBuilder = new IchibaBuilder(logManager);
2715
2716 var fileIO:FileIO = new FileIO(logManager);
2717 var fail:Boolean = false;
2718 try{
2719
2720 var html: