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