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