Esempio n. 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            var options = new BCOVTVPlayerViewOptions()
            {
                PresentingViewController = this,
            };
            var playerView         = new BCOVTVPlayerView(options);
            var playbackController = BCOVPlayerSDKManager.SharedManager().CreatePlaybackController();

            playbackController.SetAutoPlay(true);
            playbackController.SetAutoAdvance(true);
            playbackController.SetWeakDelegate(new BCPlaybackControllerDelegate());

            BCOVPlaybackService playbackService = new BCOVPlaybackService(accountId: accountID, policyKey: policyKey);

            playbackService.FindVideoWithVideoID(videoID: videoID, parameters: new NSDictionary(), completionHandler: (arg1, arg2, arg3) =>
            {
                if (arg1 != null)
                {
                    playbackController.SetVideos(NSArray.FromObjects(arg1));
                }
                else
                {
                    Debug.WriteLine($"View Controller Debug - Error retrieving video : {arg3.LocalizedDescription} ");
                }
            });

            playerView.PlaybackController = playbackController;
            //playerView.TranslatesAutoresizingMaskIntoConstraints = false;
            playerView.Frame = View.Frame;
            playerView.ControlsView.ProgressView.MinimumTrackTintColor = UIColor.Blue;
            playerView.ShowView(BCOVTVShowViewType.Controls);
            View.AddSubview(playerView);
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Google Cast button
            var castButton = new UICastButton(new CGRect(0, 0, 24, 24));

            NavigationItem.RightBarButtonItem = new UIBarButtonItem(castButton);

            //NSNotificationCenter.DefaultCenter.AddObserver(this, castDidChangeState(), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance);
            sessionManager = CastContext.SharedInstance.SessionManager;
            CastContext.SharedInstance.SessionManager.AddListener(this);

            NSNotificationCenter aNotificationCenter = NSNotificationCenter.DefaultCenter;

            aNotificationCenter.AddObserver(this, new ObjCRuntime.Selector("castDidChangeState:"), CastContext.CastStateDidChangeNotification, CastContext.SharedInstance);


            videoController = new UIView();
            videoController.BackgroundColor = UIColor.Red;
            videoController.Frame           = new CGRect(0, 100, 375, 207.5);

            //table = new UITableView(); // defaults to Plain style
            //table.Frame = new CGRect(0, 335, View.Frame.Width, View.Frame.Height - 215);
            //string[] tableItems = new string[] { "Basic Video", "DRM Video" };
            //table.Source = new TableSource(tableItems, this);

            //playbackController Setup
            playbackController = sDKManager.CreatePlaybackController();
            playbackController.SetAutoPlay(true);
            playbackController.SetAutoAdvance(true);
            playbackController.Delegate = new BCPlaybackControllerDelegate();

            BCOVGoogleCastManager googleCastManager = new BCOVGoogleCastManager();

            googleCastManager.Delegate = new BCGoogleCastManagerDelegate(playbackController);
            playbackController.AddSessionConsumer(googleCastManager);

            //playerView Setup
            var options = new BCOVPUIPlayerViewOptions()
            {
                PresentingViewController = this
            };
            var playerView = new BCOVPUIPlayerView(playbackController, options, BCOVPUIBasicControlView.BasicControlViewWithVODLayout());

            playerView.Frame = new CGRect(0, 0, 375, 207.5);


            playbackService.FindVideoWithVideoID(videoID: videoId, parameters: new NSDictionary(), completionHandler: (arg0, arg1, arg2) =>
            {
                if (arg0 != null)
                {
                    playbackController.SetVideos(NSArray.FromObjects(arg0));
                }
                else
                {
                    Debug.WriteLine($"View Controller Debug - Error retrieving video : {arg2.LocalizedDescription} ");
                }
            });

            playerView.PlaybackController = playbackController;
            videoController.AddSubview(playerView);
            View.AddSubview(videoController);
            //View.AddSubview(table);
        }