예제 #1
0
        public VideoPlayerView()
        {
            this._VideoPlayer = new MyVideoPlayer();
            this.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.VerticalOptions = LayoutOptions.FillAndExpand;

            this.Content = this._VideoPlayer;
        }
예제 #2
0
        public VideoPlayerView()
        {
            this._VideoPlayer      = new MyVideoPlayer();
            this.HorizontalOptions = LayoutOptions.FillAndExpand;
            this.VerticalOptions   = LayoutOptions.FillAndExpand;

            this.Content = this._VideoPlayer;
        }
예제 #3
0
        public MyPlayerView(MyVideoPlayer Parent)
        {
            this.BackgroundColor = UIColor.Clear;

            this._MoviePlayer = new MyMPMoviePlayerController(Parent);

            // add to subview
            this.AddSubview(this._MoviePlayer.View);
        }
예제 #4
0
        private async void PartGridView_ItemClick(object sender, ItemClickEventArgs e)
        {
            var item = e.ClickedItem as VideoPart;

            if (item.cid != _currentPartId)
            {
                _currentPartId = item.cid;
                await MyVideoPlayer.Init(_detail, _currentPartId);
            }
        }
예제 #5
0
        public async Task Init(int aid, int partId = 0, string bvId = "")
        {
            LoadingRing.IsActive = true;
            MyVideoPlayer.Close();
            DetailContainer.Visibility = Visibility.Collapsed;
            var detail = await _videoService.GetVideoDetailAsync(aid, bvId : bvId);

            LoadingRing.IsActive       = false;
            DetailContainer.Visibility = Visibility.Visible;
            if (detail != null)
            {
                await Init(detail, partId);
            }
        }
예제 #6
0
        public async Task Init(int bangumiId, bool isep = false)
        {
            LoadingRing.IsActive = true;
            MyVideoPlayer.Close();
            isEp = isep;
            DetailContainer.Visibility = Visibility.Collapsed;
            var detail = await _animeService.GetBangumiDetailAsync(bangumiId, isEp);

            LoadingRing.IsActive       = false;
            DetailContainer.Visibility = Visibility.Visible;
            if (detail != null)
            {
                await Init(detail, bangumiId);
            }
        }
예제 #7
0
        async void MyVideoPlayer_PlayerStateChanged(object sender, Octane.Xamarin.Forms.VideoPlayer.Events.VideoPlayerStateChangedEventArgs e)
        {
            if (e.CurrentState == Octane.Xamarin.Forms.VideoPlayer.Constants.PlayerState.Prepared)
            {
                MyVideoPlayer.Play();
            }

            if (e.CurrentState == Octane.Xamarin.Forms.VideoPlayer.Constants.PlayerState.Playing)
            {
                //HACK delay required for some reason. Need more time
                await System.Threading.Tasks.Task.Delay(TimeSpan.FromMilliseconds(100));

                MyVideoPlayer.Seek(StartTime);
            }
        }
예제 #8
0
        protected internal void UpdateFrame(MyVideoPlayer source)
        {
            UIApplication.SharedApplication.InvokeOnMainThread(() => {
                this._UsingFullWidth  = false;
                this._UsingFullHeight = false;

                var screenRect = UIScreen.MainScreen.Bounds;
                var w          = screenRect.Size.Width;
                var h          = screenRect.Size.Height;

                // update frame
                var f = this.Frame;
                if (source.ContentWidth <= 0)
                {
                    f.Width = w;
                    this._UsingFullWidth = true;
                }
                else
                {
                    f.Width = Convert.ToSingle(source.ContentWidth);
                }

                if (source.ContentHeight <= 0)
                {
                    f.Height = h;
                    this._UsingFullHeight = true;
                }
                else
                {
                    f.Height = Convert.ToSingle(source.ContentHeight);
                }


                this.Frame = f;
                this.SetNeedsDisplay();
            });
        }
예제 #9
0
 private void VideoPlayer_SeparateButtonClick(object sender, RoutedEventArgs e)
 {
     MyVideoPlayer.Close();
     App.AppViewModel.PlayVideoSeparate(_detail, _currentPartId, false);
 }
예제 #10
0
        public async Task Init(VideoDetail detail, int partId = 0)
        {
            Reset();
            App.AppViewModel.CurrentPlayerType  = Models.Enums.PlayerType.Video;
            App.AppViewModel.CurrentVideoPlayer = VideoPlayer;
            _detail        = detail;
            _currentPartId = partId;
            TabletMainPage.Current.SetBackgroundImage(_detail.pic);
            if (!string.IsNullOrEmpty(_detail.redirect_url))
            {
                var result = BiliTool.GetResultFromUri(_detail.redirect_url);
                videoId        = 0;
                _currentPartId = 0;
                if (result.Type == UriType.Bangumi)
                {
                    throw new InvalidDataException(result.Param);
                }
            }
            TitleBlock.Text = detail.title;
            ToolTipService.SetToolTip(TitleBlock, _detail.title);
            videoId                = _detail.aid;
            bvId                   = _detail.bvid;
            PlayCountBlock.Text    = AppTool.GetNumberAbbreviation(_detail.stat.view);
            DanmakuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmaku);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);
            BVBlock.Text           = _detail.bvid;
            AVBlock.Text           = _detail.aid.ToString();

            DescriptionBlock.Text = _detail.desc;

            LikeButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.like);
            CoinButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.coin);
            FavoriteButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.favorite);

            PublishBlock.Text = AppTool.GetReadDateString(_detail.pubdate);

            UPAvatar.ProfilePicture = string.IsNullOrEmpty(_detail.owner.face) ? null : new BitmapImage(new Uri(_detail.owner.face + "@50w.jpg"))
            {
                DecodePixelWidth = 40
            };
            UPNameBlock.Text = _detail.owner.name;

            if (_detail.pages != null)
            {
                _detail.pages.ForEach(p => VideoPartCollection.Add(p));
                PartGridView.SelectedIndex = 0;
            }
            PartContainer.Visibility = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed;
            if (_detail.tag != null && _detail.tag.Count > 0)
            {
                TagGridView.Visibility = Visibility.Visible;
                _detail.tag.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagGridView.Visibility = Visibility.Collapsed;
            }

            if (_detail.staff != null && _detail.staff.Count > 0)
            {
                _detail.staff.ForEach(p => StaffCollection.Add(p));
                SingleUserContainer.Visibility = Visibility.Collapsed;
                StaffContainer.Visibility      = Visibility.Visible;
            }
            else
            {
                StaffContainer.Visibility      = Visibility.Collapsed;
                SingleUserContainer.Visibility = Visibility.Visible;
            }

            if (_detail.req_user != null)
            {
                LikeButton.IsCheck     = _detail.req_user.like != 0;
                CoinButton.IsCheck     = _detail.req_user.coin != 0;
                FavoriteButton.IsCheck = _detail.req_user.favorite != 0;
            }

            await MyVideoPlayer.Init(_detail, _currentPartId);

            CheckLikeHoldState();
        }
예제 #11
0
        public MyMPMoviePlayerController(MyVideoPlayer Parent)
        {
            this.ParentElement = Parent;

            NSNotificationCenter.DefaultCenter.AddObserver(this,
                                                           new ObjCRuntime.Selector("LoadChangedCallback:"),
                                                           MPMoviePlayerController.LoadStateDidChangeNotification,
                                                           null
                                                           );

            this._Token = new CancellationTokenSource();

            Task.Run(async() => {
                while (true && this._Token.Token.IsCancellationRequested == false)
                {
                    await Task.Delay(TimeSpan.FromMilliseconds(200), this._Token.Token);

                    var t = this.CurrentPlaybackTime;
                    var d = this.PlayableDuration;

                    // is there a better way to calculate the end of video???
                    if (this.PlayableDuration > 1.000 && (Math.Abs(t - d) <= 0.0001 * double.Epsilon))
                    {
                        this.ParentElement.State = VideoState.ENDED;
                        this.ParentElement.Info  = new VideoData
                        {
                            State    = VideoState.ENDED,
                            At       = t,
                            Duration = d
                        };
                        this._EndOfVideo = true;
                    }
                    else
                    {
                        this._EndOfVideo = false;

                        if (this.PlaybackState == MPMoviePlaybackState.Paused)
                        {
                            this.ParentElement.State = VideoState.PAUSE;
                        }
                        else if (this.PlaybackState == MPMoviePlaybackState.Stopped)
                        {
                            this.ParentElement.State = VideoState.STOP;
                        }
                        else if (this.PlaybackState == MPMoviePlaybackState.Playing)
                        {
                            this.ParentElement.State = VideoState.PLAY;
                        }

                        if (this.PlayableDuration > 1.000)
                        {
                            this.ParentElement.Info = new VideoData
                            {
                                State    = this.ParentElement.State,
                                At       = (double.IsNaN(t) ? -1 : t),
                                Duration = d
                            };
                        }
                    }
                }
            }, this._Token.Token);
        }