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