| 21 |
import flash.utils.Timer; |
import flash.utils.Timer; |
| 22 |
|
|
| 23 |
import mx.collections.ArrayCollection; |
import mx.collections.ArrayCollection; |
|
import mx.containers.Canvas; |
|
| 24 |
import mx.controls.Alert; |
import mx.controls.Alert; |
| 25 |
import mx.controls.DataGrid; |
import mx.controls.DataGrid; |
| 26 |
import mx.controls.SWFLoader; |
import mx.controls.SWFLoader; |
| 34 |
import mx.formatters.DateFormatter; |
import mx.formatters.DateFormatter; |
| 35 |
import mx.formatters.NumberFormatter; |
import mx.formatters.NumberFormatter; |
| 36 |
|
|
| 37 |
|
import spark.components.VideoDisplay; |
| 38 |
|
|
| 39 |
import org.libspark.utils.ForcibleLoader; |
import org.libspark.utils.ForcibleLoader; |
| 40 |
import org.mineap.nicovideo4as.CommentPost; |
import org.mineap.nicovideo4as.CommentPost; |
| 41 |
import org.mineap.nicovideo4as.MyListLoader; |
import org.mineap.nicovideo4as.MyListLoader; |
| 78 |
import org.mineap.util.config.ConfigIO; |
import org.mineap.util.config.ConfigIO; |
| 79 |
import org.mineap.util.config.ConfigManager; |
import org.mineap.util.config.ConfigManager; |
| 80 |
import org.mineap.util.font.FontUtil; |
import org.mineap.util.font.FontUtil; |
| 81 |
|
import org.osmf.elements.VideoElement; |
| 82 |
import org.osmf.events.LoadEvent; |
import org.osmf.events.LoadEvent; |
| 83 |
import org.osmf.events.MediaPlayerStateChangeEvent; |
import org.osmf.events.MediaPlayerStateChangeEvent; |
| 84 |
import org.osmf.events.TimeEvent; |
import org.osmf.events.TimeEvent; |
| 85 |
import org.osmf.media.MediaPlayerState; |
import org.osmf.media.MediaPlayerState; |
| 86 |
|
import org.osmf.net.DynamicStreamingItem; |
| 87 |
import spark.components.VideoDisplay; |
import org.osmf.net.DynamicStreamingResource; |
| 88 |
|
|
| 89 |
/** |
/** |
| 90 |
* ニコニコ動画からのダウンロードを処理およびその他のGUI関連処理を行う。 |
* ニコニコ動画からのダウンロードを処理およびその他のGUI関連処理を行う。 |
| 225 |
/** 新サイズ 864×486ピクセル 旧サイズ 640×368ピクセル */ |
/** 新サイズ 864×486ピクセル 旧サイズ 640×368ピクセル */ |
| 226 |
private var _useOldVersionVideoSize:Boolean = false; |
private var _useOldVersionVideoSize:Boolean = false; |
| 227 |
|
|
| 228 |
|
private var _fmsToken:String; |
| 229 |
|
|
| 230 |
[Embed(source="/player/NNDDicons_play_20x20.png")] |
[Embed(source="/player/NNDDicons_play_20x20.png")] |
| 231 |
private var icon_Play:Class; |
private var icon_Play:Class; |
| 232 |
|
|
| 481 |
} |
} |
| 482 |
var file:File = new File(videoPath); |
var file:File = new File(videoPath); |
| 483 |
if(!file.exists){ |
if(!file.exists){ |
| 484 |
Alert.show("動画が既に存在しません。\n動画が移動されたか、削除されている可能性があります。", "エラー"); |
Alert.show("動画が既に存在しません。\n動画が移動されたか、削除されている可能性があります。", "エラー", 4, this.videoPlayer); |
| 485 |
logManager.addLog("動画が既に存在しません。動画が移動されたか、削除されている可能性があります。:" + file.nativePath); |
logManager.addLog("動画が既に存在しません。動画が移動されたか、削除されている可能性があります。:" + file.nativePath); |
|
FlexGlobals.topLevelApplication.activate(); |
|
| 486 |
return; |
return; |
| 487 |
} |
} |
| 488 |
|
|
| 638 |
if(video != null){ |
if(video != null){ |
| 639 |
HistoryManager.instance.addVideoByNNDDVideo(video); |
HistoryManager.instance.addVideoByNNDDVideo(video); |
| 640 |
}else{ |
}else{ |
| 641 |
video = new NNDDVideo("http://www.nicovideo.jp/watch/" + PathMaker.getVideoID(_videoID), videoPlayer.title, false, null, null, null, PathMaker.getThumbImgUrl(PathMaker.getVideoID(_videoID))); |
video = new NNDDVideo("http://www.nicovideo.jp/watch/" + PathMaker.getVideoID(_videoID), |
| 642 |
|
videoPlayer.title, false, null, null, null, |
| 643 |
|
PathMaker.getThumbImgUrl(PathMaker.getVideoID(_videoID))); |
| 644 |
|
|
| 645 |
HistoryManager.instance.addVideoByNNDDVideo(video, null, false); |
HistoryManager.instance.addVideoByNNDDVideo(video, null, false); |
| 646 |
} |
} |
| 667 |
videoDisplay.setConstraintValue("right", 0); |
videoDisplay.setConstraintValue("right", 0); |
| 668 |
videoDisplay.setConstraintValue("top", 0); |
videoDisplay.setConstraintValue("top", 0); |
| 669 |
|
|
| 670 |
if(videoPath.length > 4 && videoPath.substr(0,4) == "http"){ |
if(videoPath.length > 4 && (videoPath.substr(0,4) == "http" || videoPath.substr(0,4) == "rtmp") ){ |
| 671 |
// http |
// http or rtmp |
| 672 |
videoInfoView.videoServerUrl = videoPath.substring(0, videoPath.lastIndexOf("/")); |
videoInfoView.videoServerUrl = videoPath.substring(0, videoPath.lastIndexOf("/")); |
| 673 |
}else{ |
}else{ |
| 674 |
// file(ローカル) |
// file(ローカル) |
| 681 |
videoInfoView.videoType = "FLV/MP4"; |
videoInfoView.videoType = "FLV/MP4"; |
| 682 |
|
|
| 683 |
videoDisplay.autoPlay = autoPlay; |
videoDisplay.autoPlay = autoPlay; |
| 684 |
videoDisplay.source = videoPath; |
|
| 685 |
|
if (videoPath.indexOf("rtmp") == 0 && this._fmsToken != null) |
| 686 |
|
{ |
| 687 |
|
|
| 688 |
|
// RTMPの時 |
| 689 |
|
// FIXME: 未実装。だれかやり方教えて・・・。 |
| 690 |
|
|
| 691 |
|
// var resource:DynamicStreamingResource = new DynamicStreamingResource("smile-chefsf.nicovideo.jp"); |
| 692 |
|
// resource.urlIncludesFMSApplicationInstance = true; |
| 693 |
|
// var vector:Vector.<DynamicStreamingItem> = new Vector.<DynamicStreamingItem>(1); |
| 694 |
|
// vector[0] = new DynamicStreamingItem(videoPath, 1200); |
| 695 |
|
// resource.streamItems = vector; |
| 696 |
|
// var element:VideoElement = new VideoElement(resource); |
| 697 |
|
// |
| 698 |
|
// videoDisplay.source = element; |
| 699 |
|
|
| 700 |
|
// (videoDisplay.mx_internal::videoPlayer as MediaPlayer).authenticateWithToken(this._fmsToken); |
| 701 |
|
} |
| 702 |
|
else |
| 703 |
|
{ |
| 704 |
|
videoDisplay.source = videoPath; |
| 705 |
|
} |
| 706 |
videoDisplay.autoRewind = false; |
videoDisplay.autoRewind = false; |
| 707 |
videoDisplay.volume = videoPlayer.videoController.slider_volume.value; |
videoDisplay.volume = videoPlayer.videoController.slider_volume.value; |
| 708 |
videoPlayer.videoController_under.slider_volume.value = videoPlayer.videoController.slider_volume.value; |
videoPlayer.videoController_under.slider_volume.value = videoPlayer.videoController.slider_volume.value; |
| 1038 |
logManager.addLog("過去ログの取得に失敗:" + event); |
logManager.addLog("過去ログの取得に失敗:" + event); |
| 1039 |
|
|
| 1040 |
FlexGlobals.topLevelApplication.activate(); |
FlexGlobals.topLevelApplication.activate(); |
| 1041 |
Alert.show("過去ログの取得に失敗しました。\nご利用のアカウントでは過去ログを取得できない可能性があります。\n(この機能はプレミアムアカウントでのみ利用可能です。)", Message.M_ERROR); |
Alert.show("過去ログの取得に失敗しました。\nご利用のアカウントでは過去ログを取得できない可能性があります。\n(この機能はプレミアムアカウントでのみ利用可能です。)", Message.M_ERROR, 4, this.videoPlayer); |
| 1042 |
}); |
}); |
| 1043 |
renewDownloadManagerForOldComment.addEventListener(RenewDownloadManager.PROCCESS_CANCEL, function(event:Event):void{ |
renewDownloadManagerForOldComment.addEventListener(RenewDownloadManager.PROCCESS_CANCEL, function(event:Event):void{ |
| 1044 |
videoInfoView.button_oldComment_reloadFromNico.label = "更新(ニコニコ動画)"; |
videoInfoView.button_oldComment_reloadFromNico.label = "更新(ニコニコ動画)"; |
| 1064 |
renewDownloadManagerForOldComment = null; |
renewDownloadManagerForOldComment = null; |
| 1065 |
|
|
| 1066 |
FlexGlobals.topLevelApplication.activate(); |
FlexGlobals.topLevelApplication.activate(); |
| 1067 |
Alert.show("過去ログの取得に失敗しました。", Message.M_ERROR); |
Alert.show("過去ログの取得に失敗しました。", Message.M_ERROR, 4, this.videoPlayer); |
| 1068 |
}); |
}); |
| 1069 |
|
|
| 1070 |
var videoId:String = PathMaker.getVideoID(this._videoID); |
var videoId:String = PathMaker.getVideoID(this._videoID); |
| 3834 |
trace(event); |
trace(event); |
| 3835 |
logManager.addLog("\t" + CommentPost.COMMENT_POST_FAIL + ":" + event); |
logManager.addLog("\t" + CommentPost.COMMENT_POST_FAIL + ":" + event); |
| 3836 |
logManager.addLog("コメント投稿失敗"); |
logManager.addLog("コメント投稿失敗"); |
| 3837 |
Alert.show("コメントの投稿に失敗\n\n" + event.text, Message.M_ERROR); |
Alert.show("コメントの投稿に失敗\n\n" + event.text, Message.M_ERROR, 4, this.videoPlayer); |
| 3838 |
commentPost.close(); |
commentPost.close(); |
| 3839 |
}); |
}); |
| 3840 |
commentPost.addEventListener(CommentPost.COMMENT_POST_SUCCESS, function(event:Event):void{ |
commentPost.addEventListener(CommentPost.COMMENT_POST_SUCCESS, function(event:Event):void{ |
| 3876 |
* |
* |
| 3877 |
*/ |
*/ |
| 3878 |
public function playMovie(url:String, playList:PlayList = null, playListIndex:int = -1, videoTitle:String = "", isEconomy:Boolean = false):void{ |
public function playMovie(url:String, playList:PlayList = null, playListIndex:int = -1, videoTitle:String = "", isEconomy:Boolean = false):void{ |
| 3879 |
|
_playMovie(url, null, playList, playListIndex, videoTitle, isEconomy); |
| 3880 |
|
} |
| 3881 |
|
|
| 3882 |
|
/** |
| 3883 |
|
* 渡されたURLで動画を再生します。 |
| 3884 |
|
* |
| 3885 |
|
* @param url 再生したい動画のURL(ローカルの場合でもURL形式ならば有効) |
| 3886 |
|
* @param token Flash Media Serverの認証を行うためのトークン |
| 3887 |
|
* @param playList プレイリストの場合はPlayListを指定 |
| 3888 |
|
* @param playListIndex プレイリスト内でどの項目を再生するか指定 |
| 3889 |
|
* @param videoTitle ストリーミング再生等で動画のタイトルを取得するのが難しい場合は動画のタイトルを指定します。 |
| 3890 |
|
* @param isEconomy エコノミーモードで再生するかどうかです。デフォルトではfalseで、エコノミーモードで再生しません。 |
| 3891 |
|
* |
| 3892 |
|
*/ |
| 3893 |
|
public function _playMovie(url:String, token:String = null, playList:PlayList = null, playListIndex:int = -1, videoTitle:String = "", isEconomy:Boolean = false):void{ |
| 3894 |
|
|
| 3895 |
try{ |
try{ |
| 3896 |
|
|
| 3897 |
|
this._fmsToken = token; |
| 3898 |
|
|
| 3899 |
this.videoPlaying = true; |
this.videoPlaying = true; |
| 3900 |
|
|
| 3901 |
if(videoInfoView != null){ |
if(videoInfoView != null){ |
| 3948 |
|
|
| 3949 |
setPlayed(PathMaker.getVideoID(url)); |
setPlayed(PathMaker.getVideoID(url)); |
| 3950 |
|
|
| 3951 |
if(url.indexOf("http://") == -1){ |
if(url.indexOf("http://") == -1 && url.indexOf("rtmp") == -1){ |
| 3952 |
/* ---- ローカルの動画を再生 ---- */ |
/* ---- ローカルの動画を再生 ---- */ |
| 3953 |
|
|
| 3954 |
videoPlayer.title = url; |
videoPlayer.title = url; |
| 4009 |
} |
} |
| 4010 |
|
|
| 4011 |
if(!file.exists){ |
if(!file.exists){ |
| 4012 |
Alert.show(Message.M_FILE_NOT_FOUND_REFRESH + "\n" + file.nativePath, Message.M_ERROR); |
Alert.show(Message.M_FILE_NOT_FOUND_REFRESH + "\n" + file.nativePath, Message.M_ERROR, 4, this.videoPlayer); |
| 4013 |
logManager.addLog(Message.M_FILE_NOT_FOUND_REFRESH + "\n" + file.nativePath); |
logManager.addLog(Message.M_FILE_NOT_FOUND_REFRESH + "\n" + file.nativePath); |
|
FlexGlobals.topLevelApplication.activate(); |
|
| 4014 |
return; |
return; |
| 4015 |
} |
} |
| 4016 |
|
|
| 4043 |
this.init(url, PlayerController.WINDOW_TYPE_FLV, comments, PathMaker.createThmbInfoPathByVideoPath(url, false), true, false, null, false, videoTitle); |
this.init(url, PlayerController.WINDOW_TYPE_FLV, comments, PathMaker.createThmbInfoPathByVideoPath(url, false), true, false, null, false, videoTitle); |
| 4044 |
} |
} |
| 4045 |
} |
} |
| 4046 |
}else if(url.match(new RegExp("http://smile")) != null || url.match(new RegExp("http://[^/]+/NNDDServer/.*")) != null){ |
}else if((url.match(new RegExp("http://smile.*")) != null) |
| 4047 |
|
|| (url.match(new RegExp("http://[^/]+/NNDDServer/.*")) != null ) |
| 4048 |
|
|| (url.match(new RegExp("rtmp[^:]*://smile.*")) != null)){ |
| 4049 |
|
|
| 4050 |
/* ストリーミング再生(接続先動画サーバがわかっている時) */ |
/* ストリーミング再生(接続先動画サーバがわかっている時) */ |
| 4051 |
|
|
| 4052 |
logManager.addLog("***動画の再生(ストリーミング)***"); |
logManager.addLog("***動画の再生(ストリーミング)***"); |
| 4053 |
|
|
| 4054 |
|
if (url.indexOf("rtmp") == 0) |
| 4055 |
|
{ |
| 4056 |
|
Alert.show(videoPlayer.title + " を再生できませんでした。\n\nこの動画はrtmp形式で配信されていますが、NNDDはrtmp形式の動画の再生に対応していません。", "エラー", 4, this.videoPlayer); |
| 4057 |
|
logManager.addLog("rtmp形式の動画の再生には非対応:" + url); |
| 4058 |
|
|
| 4059 |
|
return; |
| 4060 |
|
} |
| 4061 |
|
|
| 4062 |
var commentPath:String = libraryManager.tempDir.url + "/nndd.xml"; |
var commentPath:String = libraryManager.tempDir.url + "/nndd.xml"; |
| 4063 |
var ownerCommentPath:String = libraryManager.tempDir.url + "/nndd[Owner].xml"; |
var ownerCommentPath:String = libraryManager.tempDir.url + "/nndd[Owner].xml"; |
| 4064 |
|
|
| 4154 |
nnddDownloaderForStreaming._otherNNDDServerAddress = nnddServerAddress; |
nnddDownloaderForStreaming._otherNNDDServerAddress = nnddServerAddress; |
| 4155 |
nnddDownloaderForStreaming._otherNNDDServerPort = nnddServerPortNum; |
nnddDownloaderForStreaming._otherNNDDServerPort = nnddServerPortNum; |
| 4156 |
nnddDownloaderForStreaming.addEventListener(NNDDDownloader.DOWNLOAD_PROCESS_COMPLETE, function(event:Event):void{ |
nnddDownloaderForStreaming.addEventListener(NNDDDownloader.DOWNLOAD_PROCESS_COMPLETE, function(event:Event):void{ |
| 4157 |
playMovie((event.target as NNDDDownloader).streamingUrl, playList, playListIndex, (event.target as NNDDDownloader).nicoVideoName, nnddDownloaderForStreaming.isEconomyMode); |
_playMovie((event.target as NNDDDownloader).streamingUrl, |
| 4158 |
|
(event.target as NNDDDownloader).fmsToken, |
| 4159 |
|
playList, playListIndex, |
| 4160 |
|
(event.target as NNDDDownloader).nicoVideoName, |
| 4161 |
|
nnddDownloaderForStreaming.isEconomyMode); |
| 4162 |
|
|
| 4163 |
removeStreamingPlayHandler(event); |
removeStreamingPlayHandler(event); |
| 4164 |
nnddDownloaderForStreaming = null; |
nnddDownloaderForStreaming = null; |
| 4165 |
|
|
| 4225 |
videoPlayer.label_downloadStatus.text = ""; |
videoPlayer.label_downloadStatus.text = ""; |
| 4226 |
videoPlayer.setControllerEnable(true); |
videoPlayer.setControllerEnable(true); |
| 4227 |
|
|
| 4228 |
Alert.show("ストリーミング再生中に予期せぬ例外が発生しました。\nError:" + e, Message.M_ERROR); |
Alert.show("ストリーミング再生中に予期せぬ例外が発生しました。\nError:" + e, Message.M_ERROR, 4, this.videoPlayer); |
| 4229 |
logManager.addLog("ストリーミング再生中に予期せぬ例外が発生しました。\nError:" + e + ":" + e.getStackTrace()); |
logManager.addLog("ストリーミング再生中に予期せぬ例外が発生しました。\nError:" + e + ":" + e.getStackTrace()); |
|
FlexGlobals.topLevelApplication.activate(); |
|
| 4230 |
nnddDownloaderForStreaming.close(true, true); |
nnddDownloaderForStreaming.close(true, true); |
| 4231 |
nnddDownloaderForStreaming = null; |
nnddDownloaderForStreaming = null; |
| 4232 |
|
|
| 4239 |
}catch(error:Error){ |
}catch(error:Error){ |
| 4240 |
trace(error.getStackTrace()); |
trace(error.getStackTrace()); |
| 4241 |
videoPlayer.setControllerEnable(true); |
videoPlayer.setControllerEnable(true); |
| 4242 |
Alert.show(url + "を再生できませんでした。\n" + error, Message.M_ERROR); |
Alert.show(url + "を再生できませんでした。\n" + error, Message.M_ERROR, 4, this.videoPlayer); |
| 4243 |
logManager.addLog("再生できませんでした:url=[" + url + "]\n" + error.getStackTrace()); |
logManager.addLog("再生できませんでした:url=[" + url + "]\n" + error.getStackTrace()); |
|
FlexGlobals.topLevelApplication.activate(); |
|
| 4244 |
} |
} |
| 4245 |
} |
} |
| 4246 |
|
|
| 4520 |
if(videoId != null){ |
if(videoId != null){ |
| 4521 |
WebServiceAccessUtil.openNiconicoDougaForVideo(videoId); |
WebServiceAccessUtil.openNiconicoDougaForVideo(videoId); |
| 4522 |
}else{ |
}else{ |
| 4523 |
Alert.show("動画IDが見つからないため、URLを特定できませんでした。", Message.M_ERROR); |
Alert.show("動画IDが見つからないため、URLを特定できませんでした。", Message.M_ERROR, 4, this.videoPlayer); |
| 4524 |
logManager.addLog("ニコ動での閲覧に失敗:動画IDが見つからないため、URLを特定できませんでした。"); |
logManager.addLog("ニコ動での閲覧に失敗:動画IDが見つからないため、URLを特定できませんでした。"); |
| 4525 |
} |
} |
| 4526 |
} |
} |
| 4617 |
(FlexGlobals.topLevelApplication as NNDD).addDownloadListForInfoView(video); |
(FlexGlobals.topLevelApplication as NNDD).addDownloadListForInfoView(video); |
| 4618 |
logManager.addLog("InfoViewからDLリストへ追加:" + video.getDecodeUrl()); |
logManager.addLog("InfoViewからDLリストへ追加:" + video.getDecodeUrl()); |
| 4619 |
}else{ |
}else{ |
| 4620 |
Alert.show("動画IDが見つからないため、DLリストに追加できませんでした。", Message.M_ERROR); |
Alert.show("動画IDが見つからないため、DLリストに追加できませんでした。", Message.M_ERROR, 4, this.videoPlayer); |
| 4621 |
logManager.addLog("DLリストへの追加失敗:動画IDが見つからないため、DLリストに動画を追加できませんでした。"); |
logManager.addLog("DLリストへの追加失敗:動画IDが見つからないため、DLリストに動画を追加できませんでした。"); |
| 4622 |
} |
} |
| 4623 |
} |
} |