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