public void OpenHyperLink(object sender, RequestNavigateEventArgs e) { var url = e.Uri.OriginalString; if (DataContext is VideoViewModel) { var vm = (VideoViewModel)DataContext; if (url.StartsWith("#")) { vm.Handler.Seek(NicoNicoUtil.ConvertTime((url.Substring(1)))); } else { if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift) || NicoNicoOpener.GetType(e.Uri.OriginalString) != NicoNicoUrlType.Video) { NicoNicoOpener.Open(e.Uri.OriginalString); } else { //URLを書き換えて再読込 vm.VideoUrl = e.Uri.OriginalString; vm.Initialize(); } } } }
public void OpenHyperLink(object sender, RequestNavigateEventArgs e) { var url = e.Uri.OriginalString; if (url.StartsWith("#")) { if (DataContext is VideoViewModel) { var vm = (VideoViewModel)DataContext; var time = url.Substring(1); vm.Handler.Seek(NicoNicoUtil.ConvertTime((time))); } } else { if (DataContext is VideoViewModel) { var vm = (VideoViewModel)DataContext; if (Keyboard.IsKeyDown(Key.LeftCtrl) || Keyboard.IsKeyDown(Key.LeftShift) || NicoNicoOpener.GetType(e.Uri.OriginalString) != NicoNicoUrlType.Video) { NicoNicoOpener.Open(e.Uri.OriginalString); } else { NicoNicoOpener.Replace(vm, e.Uri.OriginalString); vm.DisposeViewModel(); } } } }
private void MenuItem_Click(object sender, RoutedEventArgs e) { var vm = ((MenuItem)sender).DataContext as CommentEntryViewModel; var time = NicoNicoUtil.ConvertTime(vm.Entry.RenderTime); DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => vm.Owner.Handler.Seek(time))); }
public void OpenHyperLink(object sender, RequestNavigateEventArgs e) { var url = e.Uri.OriginalString; if (url.StartsWith("#")) { if (DataContext is VideoViewModel) { VideoViewModel vm = (VideoViewModel)DataContext; var time = url.Substring(1); vm.Seek(NicoNicoUtil.ConvertTime((time))); } } else { NicoNicoOpener.Open(e.Uri.OriginalString); } }
private void Seek_MouseMove(object sender, MouseEventArgs e) { if (!(DataContext is VideoViewModel)) { return; } VideoViewModel vm = (VideoViewModel)DataContext; //マウスカーソルX座標 double x = e.GetPosition(this).X; //シーク中の動画時間 int ans = (int)(x / ActualWidth * Seek.VideoTime); if (ans < 0 || Seek.VideoTime < ans) { return; } Seek.PopupText = NicoNicoUtil.ConvertTime(ans); Seek.PopupRect = new Rect(x - 5, 0, 20, 20); if (Seek.IsPopupImageOpen) { NicoNicoStoryBoardData Story = vm.VideoData.StoryBoardData; if (Story.BitmapCollection.ContainsKey(ans - ans % Story.Interval)) { Seek.PopupImageRect = new Rect(x - Story.Width / 2, -10, Story.Width, Story.Height); Bitmap test = Story.BitmapCollection[ans - ans % Story.Interval]; IntPtr hBitMap = test.GetHbitmap(); try { Seek.PopupImage = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(hBitMap, IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()); } finally { DeleteObject(hBitMap); } } } }
public void OpenTweetView() { var query = new GetRequestQuery("https://twitter.com/intent/tweet"); query.AddQuery("url", Uri.EscapeDataString("http://www.nicovideo.jp" + new Uri(VideoUrl).AbsolutePath)); query.AddQuery("hashtags", ApiData.Video.Id); query.AddQuery("original_referer", Uri.EscapeDataString(VideoUrl)); query.AddQuery("text", Uri.EscapeDataString(ApiData.Video.Title + "(" + NicoNicoUtil.ConvertTime(ApiData.Video.Duration) + ")")); TweetBrowser = new WebBrowser(); TweetBrowser.Navigating += (obj, e) => { if (e.Uri.Query == "") { TweetPopupOpen = false; } }; TweetPopupOpen = true; TweetBrowser.Navigate(query.TargetUrl); }
private void Seek_MouseMove(object sender, MouseEventArgs e) { if (!(DataContext is LiveWatchViewModel)) { return; } var vm = (LiveWatchViewModel)DataContext; //マウスカーソルX座標 double x = e.GetPosition(this).X; //シーク中の動画時間 int ans = (int)(x / ActualWidth * Seek.VideoTime); if (ans < 0 || Seek.VideoTime < ans) { return; } Seek.PopupText = NicoNicoUtil.ConvertTime(ans); Seek.PopupRect = new Rect(x - 5, 0, 20, 20); }
//指定した時間でシークバーを移動する private void SetSeekCursor(float time) { Time.CurrentTime = (int)time; Time.CurrentTimeString = NicoNicoUtil.ConvertTime(Time.CurrentTime); }
private void Initialize(string videoUrl) { IsActive = true; Task.Run(() => { Mylist = new VideoMylistViewModel(this); VideoData = new VideoData(); Status = "動画情報取得中"; //動画情報取得 VideoData.ApiData = NicoNicoWatchApi.GetWatchApiData(videoUrl); //ロードに失敗したら if (VideoData.ApiData == null) { LoadFailed = true; IsActive = false; Status = "動画の読み込みに失敗しました。"; return; } //有料動画なら if (VideoData.ApiData.IsPaidVideo) { App.ViewModelRoot.Messenger.Raise(new TransitionMessage(typeof(PaidVideoDialog), this, TransitionMode.Modal)); return; } DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => { while (VideoFlash == null) { Thread.Sleep(1); } if (VideoData.ApiData.Cmsid.Contains("nm")) { VideoData.VideoType = NicoNicoVideoType.SWF; WebBrowser.Source = new Uri(GetNMPlayerPath()); } else if (VideoData.ApiData.GetFlv.VideoUrl.StartsWith("rtmp")) { VideoData.VideoType = NicoNicoVideoType.RTMP; WebBrowser.Source = new Uri(GetRTMPPlayerPath()); } else { if (VideoData.ApiData.MovieType == "flv") { VideoData.VideoType = NicoNicoVideoType.FLV; } else { VideoData.VideoType = NicoNicoVideoType.MP4; } WebBrowser.Source = new Uri(GetPlayerPath()); } })); IsActive = false; Time = new VideoTime(); //動画時間 Time.VideoTimeString = NicoNicoUtil.ConvertTime(VideoData.ApiData.Length); if (VideoData.ApiData.GetFlv.IsPremium && !VideoData.ApiData.GetFlv.VideoUrl.StartsWith("rtmp")) { Task.Run(() => { Status = "ストーリーボード取得中"; NicoNicoStoryBoard sb = new NicoNicoStoryBoard(VideoData.ApiData.GetFlv.VideoUrl); VideoData.StoryBoardData = sb.GetStoryBoardData(); Status = "ストーリーボード取得完了"; }); } NicoNicoComment comment = new NicoNicoComment(VideoData.ApiData.GetFlv, this); List <NicoNicoCommentEntry> list = comment.GetComment(); if (list != null) { foreach (NicoNicoCommentEntry entry in list) { VideoData.CommentData.Add(new CommentEntryViewModel(entry)); } dynamic json = new DynamicJson(); json.array = list; DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => InjectComment(json.ToString()))); } if (!Properties.Settings.Default.CommentVisibility) { DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => InvokeScript("JsToggleComment"))); } else { CommentVisibility = true; } //App.ViewModelRoot.StatusBar.Status = "動画取得完了"; }); }
public async void Initialize(VideoData videoData) { while (!IsPreIntialized) { Thread.Sleep(1); } VideoData = videoData; //ロードに失敗したら if (VideoData.ApiData == null) { Owner.LoadFailed = true; Owner.IsActive = false; Owner.Status = "動画の読み込みに失敗しました。"; return; } Owner.Name = VideoData.ApiData.Title; //有料動画なら if (VideoData.ApiData.IsPaidVideo) { App.ViewModelRoot.Messenger.Raise(new TransitionMessage(typeof(PaidVideoDialog), Owner, TransitionMode.Modal)); return; } await DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => { Proxy.ExternalInterfaceCall += new ExternalInterfaceCallEventHandler(ExternalInterfaceHandler); if (ShockwaveFlash.IsDisposed) { return; } if (VideoData.ApiData.Cmsid.Contains("nm")) { VideoData.VideoType = NicoNicoVideoType.SWF; ShockwaveFlash.LoadMovie(0, GetNMPlayerPath()); } else if (VideoData.ApiData.GetFlv.VideoUrl.StartsWith("rtmp")) { VideoData.VideoType = NicoNicoVideoType.RTMP; ShockwaveFlash.LoadMovie(0, GetRTMPPlayerPath()); } else { if (VideoData.ApiData.MovieType == "flv") { VideoData.VideoType = NicoNicoVideoType.FLV; } else { VideoData.VideoType = NicoNicoVideoType.MP4; } ShockwaveFlash.LoadMovie(0, GetPlayerPath()); } Owner.IsActive = false; })); //動画時間 Owner.Time.VideoTimeString = NicoNicoUtil.ConvertTime(VideoData.ApiData.Length); Owner.Time.Length = VideoData.ApiData.Length; if (VideoData.ApiData.GetFlv.IsPremium && !VideoData.ApiData.GetFlv.VideoUrl.StartsWith("rtmp")) { Owner.StoryBoardStatus = "取得中"; var sb = new NicoNicoStoryBoard(VideoData.ApiData.GetFlv.VideoUrl); VideoData.StoryBoardData = sb.GetStoryBoardData(); if (VideoData.StoryBoardData == null) { Owner.StoryBoardStatus = "データ無し"; } else { Owner.StoryBoardStatus = "取得完了"; } } else { Owner.StoryBoardStatus = "データ無し"; } Owner.CommentInstance = new NicoNicoComment(VideoData.ApiData, Owner); InitializeComment(); }
public void Initialize() { DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => { if (IsFullScreen) { FullScreenVideoFlash = new VideoFlash() { DataContext = this }; FullScreenContoller = new VideoController() { DataContext = this }; } else { VideoFlash = new VideoFlash() { DataContext = this }; Controller = new VideoController() { DataContext = this }; } })); var videoUrl = VideoUrl + "?watch_harmful=1"; IsActive = true; Task.Run(() => { Mylist = new VideoMylistViewModel(this); Comment = new VideoCommentViewModel(this); VideoData = new VideoData(); Status = "動画情報取得中"; //動画情報取得 WatchApi = new NicoNicoWatchApi(videoUrl, this); VideoData.ApiData = WatchApi.GetWatchApiData(); //ロードに失敗したら if (VideoData.ApiData == null) { LoadFailed = true; IsActive = false; Status = "動画の読み込みに失敗しました。"; return; } //有料動画なら if (VideoData.ApiData.IsPaidVideo) { App.ViewModelRoot.Messenger.Raise(new TransitionMessage(typeof(PaidVideoDialog), this, TransitionMode.Modal)); return; } DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => { if (VideoData.ApiData.Cmsid.Contains("nm")) { VideoData.VideoType = NicoNicoVideoType.SWF; ShockwaveFlash.LoadMovie(0, GetNMPlayerPath()); } else if (VideoData.ApiData.GetFlv.VideoUrl.StartsWith("rtmp")) { VideoData.VideoType = NicoNicoVideoType.RTMP; ShockwaveFlash.LoadMovie(0, GetRTMPPlayerPath()); } else { if (VideoData.ApiData.MovieType == "flv") { VideoData.VideoType = NicoNicoVideoType.FLV; } else { VideoData.VideoType = NicoNicoVideoType.MP4; } ShockwaveFlash.LoadMovie(0, GetPlayerPath()); } Proxy.ExternalInterfaceCall += new ExternalInterfaceCallEventHandler(ExternalInterfaceHandler); IsActive = false; Task.Run(() => { OpenVideo(); }); })); Time = new VideoTime(); //動画時間 Time.VideoTimeString = NicoNicoUtil.ConvertTime(VideoData.ApiData.Length); if (VideoData.ApiData.GetFlv.IsPremium && !VideoData.ApiData.GetFlv.VideoUrl.StartsWith("rtmp")) { Task.Run(() => { StoryBoardStatus = "取得中"; var sb = new NicoNicoStoryBoard(VideoData.ApiData.GetFlv.VideoUrl); VideoData.StoryBoardData = sb.GetStoryBoardData(); if (VideoData.StoryBoardData == null) { StoryBoardStatus = "データ無し"; } else { StoryBoardStatus = "取得完了"; } }); } else { StoryBoardStatus = "データ無し"; } CommentInstance = new NicoNicoComment(VideoData.ApiData, this); var list = CommentInstance.GetComment(); if (list != null) { foreach (var entry in list) { VideoData.CommentData.Add(new CommentEntryViewModel(entry)); } dynamic json = new DynamicJson(); json.array = list; InjectComment(json.ToString()); Comment.CanComment = true; //投稿者コメントがあったら取得する if (VideoData.ApiData.HasOwnerThread) { var ulist = CommentInstance.GetUploaderComment(); dynamic ujson = new DynamicJson(); json.array = ulist; InjectUploaderComment(json.ToString()); } //コメント設定を反映 ApplyChanges(); } if (!Properties.Settings.Default.CommentVisibility) { InvokeScript("AsToggleComment"); } else { CommentVisibility = true; } }); }