예제 #1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestedOrientation = Android.Content.PM.ScreenOrientation.Landscape;
            base.OnCreate(savedInstanceState);

            castSessionManagerListener = new CastSessionManagerListener(this);
            castContext = CastContext.GetSharedInstance(this);
            castSession = castContext.SessionManager.CurrentCastSession;
            castContext.SessionManager.AddSessionManagerListener(castSessionManagerListener);

            //setup layout and video data
            SetContentView(Resource.Layout.playerPageLayout);
            mediaInfo = chromecastService.Value.GetPlaybackAsset();

            //TITLE
            assetTitle          = FindViewById <TextView>(Resource.Id.assetTitle);
            assetTitle.Text     = mediaInfo.DisplayName;
            assetTitle.TextSize = 20;

            //BACKBUTTON
            backButton        = FindViewById <Button>(Resource.Id.backButton);
            backButton.Click += BackButton_Click;

            //Cast Button setup
            castButton = (MediaRouteButton)FindViewById(Resource.Id.media_route_button);
            CastButtonFactory.SetUpMediaRouteButton(ApplicationContext, castButton);

            //VideoPlayer Source
            videoView = FindViewById <VideoView>(Resource.Id.video_view);
            var videoURL = Android.Net.Uri.Parse(mediaInfo.SourceURL);

            mController = new Android.Widget.MediaController(this);
            mController.SetAnchorView(videoView);
            videoView.SetVideoURI(videoURL);
            videoView.SetMediaController(mController);

            if (mLocation == PlaybackLocation.LOCAL)
            {
                videoView.Start();
            }
            else
            {
                castSession = castContext.SessionManager.CurrentCastSession;
                if ((castSession != null) && (castSession.IsConnected == true))
                {
                    //setup media to send to cast receiver
                    mLocation = PlaybackLocation.REMOTE;
                    var test = castContext.SessionManager.CurrentCastSession;

                    //call/initialize customCastMediaManager if needed. this sample uses default things
                }
            }
        }
예제 #2
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);

            CastContext castContext = CastContext.GetSharedInstance(this);

            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            LoadApplication(new App());
        }
예제 #3
0
        private void InitCast()
        {
            castContext = CastContext.GetSharedInstance(this.ApplicationContext);

            castContext.SessionManager.AddSessionManagerListener(this);

            //var prov = new MediaRouteActionProvider(Application.Context);

            callback = new MediaRouteSelectorCallback();

            mediaRouteSelector = new MediaRouteSelector.Builder()
                                 // These are the framework-supported intents
                                 .AddControlCategory(MediaControlIntent.CategoryRemotePlayback)
                                 .AddControlCategory(MediaControlIntent.CategoryLiveAudio)
                                 .AddControlCategory(CastMediaControlIntent.CategoryForCast(CastMediaControlIntent.DefaultMediaReceiverApplicationId))
                                 .Build();

            mediaRouter = MediaRouter.GetInstance(this.ApplicationContext);
        }
예제 #4
0
        // Activity lifecycle methods.

        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            //Getting the cast context later than onStart can cause device discovery not to take place.
            castContext = CastContext.GetSharedInstance(this);

            SetContentView(Resource.Layout.main_activity);

            localPlayerView = (PlayerView)FindViewById(Resource.Id.local_player_view);
            localPlayerView.RequestFocus();

            castControlView = (PlayerControlView)FindViewById(Resource.Id.cast_control_view);

            mediaQueueListAdapter = new MediaQueueListAdapter();
            mediaQueueList        = (RecyclerView)FindViewById(Resource.Id.sample_list);
            mediaQueueList.SetLayoutManager(new LinearLayoutManager(this));
            mediaQueueList.HasFixedSize = true;

            ItemTouchHelper helper = new ItemTouchHelper(new RecyclerViewCallback(playerManager, mediaQueueListAdapter));

            helper.AttachToRecyclerView(mediaQueueList);

            FindViewById(Resource.Id.add_sample_button).SetOnClickListener(this);
        }