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