Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /NNDDv2/trunk/src/org/mineap/nndd/player/PlayerController.as

Parent Directory Parent Directory | Revision Log Revision Log


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