Inheritance: Livet.ViewModel
Exemplo n.º 1
0
        public async void Initialize()
        {
            IsActive = true;

            ApiData = await WatchiApiInstance.GetWatchApiDataAsync();

            if (ApiData == null)
            {
                return;
            }

            Name = ApiData.Video.Title;

            //タグ情報を初期化して追加
            TagList.Clear();
            foreach (var tag in ApiData.Tags)
            {
                TagList.Add(new VideoTagViewModel(tag, this));
            }

            IsActive = false;
            //コメントを取得
            Comment = new VideoCommentViewModel(this);

            Mylist = new VideoMylistViewModel(this);


            if (IsFullScreen)
            {
                FullScreenController = new Views.VideoController()
                {
                    DataContext = this
                };
                FullScreenWebBrowser           = new WebBrowser();
                FullScreenWebBrowser.Focusable = false;

                Handler?.Dispose();
                Handler = new VideoHtml5Handler(FullScreenWebBrowser);
                Handler.Initialize(this);
            }
            else
            {
                Controller = new Views.VideoController()
                {
                    DataContext = this
                };
                WebBrowser           = new WebBrowser();
                WebBrowser.Focusable = false;

                Handler?.Dispose();
                Handler = new VideoHtml5Handler(WebBrowser);
                Handler.Initialize(this);
            }

            await Comment.Initialize();

            //画像処理をUIスレッドでやられると重いので
            await Task.Run(async() => StoryBoardList = await StoryBoardInstance.GetVideoStoryBoardAsync(ApiData.Video.SmileInfo.Url));
        }
Exemplo n.º 2
0
        public async void Initialize()
        {
            Mylist    = new VideoMylistViewModel(this);
            Comment   = new VideoCommentViewModel(this);
            Handler   = new VideoFlashHandler(this);
            Time      = new VideoTime();
            VideoData = new VideoData();

            await DispatcherHelper.UIDispatcher.BeginInvoke(new Action(() => {
                if (IsFullScreen)
                {
                    FullScreenVideoFlash = new VideoFlash()
                    {
                        DataContext = this
                    };
                    FullScreenController = new VideoController()
                    {
                        DataContext = this
                    };
                }
                else
                {
                    VideoFlash = new VideoFlash()
                    {
                        DataContext = this
                    };
                    Controller = new VideoController()
                    {
                        DataContext = this
                    };
                }
            }));

            var videoUrl = VideoUrl + "?watch_harmful=1";

            IsActive = true;

            Status = "動画情報取得中";
            //動画情報取得

            await Task.Run(() => {
                WatchApi          = new NicoNicoWatchApi(videoUrl, this);
                VideoData.ApiData = WatchApi.GetWatchApiData();
                Handler.Initialize(VideoData);
            });
        }
Exemplo n.º 3
0
        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 = "動画取得完了";
            });
        }
Exemplo n.º 4
0
        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 = "動画取得完了";
            });
        }
Exemplo n.º 5
0
        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;
                }
            });
        }
Exemplo n.º 6
0
        public VideoViewModel(string videoUrl, PlayListViewModel playList = null) : base(videoUrl.Substring(30)) {

            PlayList = playList;

            if(videoUrl.Contains("?")) {

                videoUrl = videoUrl.Split('?')[0];
                Name = videoUrl.Substring(30);
            }

            VideoUrl = videoUrl;
            Cmsid = Name;

            Mylist = new VideoMylistViewModel(this);
            Comment = new VideoCommentViewModel(this);
            Handler = new VideoFlashHandler(this);
            Time = new VideoTime();
            VideoData = new VideoData();
            InitializeView();
        }