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