Ejemplo n.º 1
0
        static void InitChromeMediaSession()
        {
            var mediaCallback = new ChromeMediaSessionCallback();

            mediaSession = new MediaSessionCompat(Application.Context, "Chromecast");
            mediaSession.SetCallback(mediaCallback);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Will register for the remote control client commands in audio manager
        /// </summary>
        private void InitMediaSession()
        {
            try
            {
                if (mediaSessionCompat == null)
                {
                    Intent        nIntent = new Intent(this.ApplicationContext, typeof(MainActivity));
                    PendingIntent pIntent = PendingIntent.GetActivity(this.ApplicationContext, 0, nIntent, 0);

                    remoteComponentName = new ComponentName(this.PackageName, new RemoteControlBroadcastReceiver().ComponentName);

                    mediaSessionCompat    = new MediaSessionCompat(this.ApplicationContext, "XamarinStreamingAudio", remoteComponentName, pIntent);
                    mediaControllerCompat = new MediaControllerCompat(this.ApplicationContext, mediaSessionCompat.SessionToken);
                }

                mediaSessionCompat.Active = true;
                mediaSessionCompat.SetCallback(new MediaSessionCallback((MediaPlayerServiceBinder)binder));

                mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        internal void InitMediaSession(string packageName, MediaServiceBinder binder)
        {
            try
            {
                if (mediaSessionCompat == null)
                {
                    Intent nIntent = new Intent(applicationContext, typeof(MediaPlayer));
                    PendingIntent pIntent = PendingIntent.GetActivity(applicationContext, 0, nIntent, 0);

                    RemoteComponentName = new ComponentName(packageName, new RemoteControlBroadcastReceiver().ComponentName);
                    mediaSessionCompat = new MediaSessionCompat(applicationContext, "XamarinStreamingAudio", RemoteComponentName, pIntent);
                    mediaControllerCompat = new MediaControllerCompat(applicationContext, mediaSessionCompat.SessionToken);
                    NotificationManager = new MediaNotificationManagerImplementation(applicationContext, CurrentSession.SessionToken, _serviceType);
                }
                mediaSessionCompat.Active = true;
                mediaSessionCompat.SetCallback(binder.GetMediaPlayerService<MediaServiceBase>().AlternateRemoteCallback ?? new MediaSessionCallback(this));
                mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
                _packageName = packageName;
                _binder = binder;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
        internal void InitMediaSession(string packageName, MediaServiceBinder binder)
        {
            try
            {
                if (mediaSessionCompat == null)
                {
                    Intent        nIntent = new Intent(applicationContext, typeof(MediaPlayer));
                    PendingIntent pIntent = PendingIntent.GetActivity(applicationContext, 0, nIntent, 0);

                    RemoteComponentName   = new ComponentName(packageName, new RemoteControlBroadcastReceiver().ComponentName);
                    mediaSessionCompat    = new MediaSessionCompat(applicationContext, "XamarinStreamingAudio", RemoteComponentName, pIntent);
                    mediaControllerCompat = new MediaControllerCompat(applicationContext, mediaSessionCompat.SessionToken);
                }
                mediaSessionCompat.Active = true;
                //mediaSessionCompat.SetCallback(binder.GetMediaPlayerService().AlternateRemoteCallback ?? new MediaSessionCallback(binder));
                mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
                NotificationManager = new MediaNotificationManagerImplementation(applicationContext, CurrentSession.SessionToken, typeof(MediaPlayerService));
                _packageName        = packageName;
                _binder             = binder;
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
            }
        }
Ejemplo n.º 5
0
        public void Initialize(Context context)
        {
            mMessageReceiver = new MusicControlsBroadcastReceiver(this);
            RegisterBroadcaster(context, mMessageReceiver);

            mediaSessionCompat = new MediaSessionCompat(context, "music-controls-media-session", null, mediaButtonPendingIntent);
            mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);

            SetMediaPlaybackState((int)PlaybackStateCompat.StatePaused);

            mediaSessionCompat.Active = true;
            mediaSessionCompat.SetCallback(mMediaSessionCallback);

            try
            {
                mAudioManager = (AudioManager)context.GetSystemService(Context.AudioService);
                var headsetIntent = new Intent(musicControlsButton);
                mediaButtonPendingIntent = PendingIntent.GetBroadcast(context, 0, headsetIntent, PendingIntentFlags.UpdateCurrent);
                RegisterMediaButtonEvent();

                //MediaButtonReceiver.HandleIntent(mediaSessionCompat, headsetIntent);
                //BroadcastReceiver.
            }
            catch (Exception exc)
            {
            }
        }
Ejemplo n.º 6
0
        public override void OnCreate()
        {
            base.OnCreate();

            // Create a MediaSessionCompat
            mMediaSession = new MediaSessionCompat(ApplicationContext, LogTag);

            // Enable callbacks from MediaButtons and TransportControls
            mMediaSession.SetFlags(
                MediaSessionCompat.FlagHandlesMediaButtons |
                MediaSessionCompat.FlagHandlesTransportControls);

            // Set an initial PlaybackState with ACTION_PLAY, so media buttons can start the player
            mStateBuilder = new PlaybackStateCompat.Builder()
                            .SetActions(
                PlaybackStateCompat.ActionPlay |
                PlaybackStateCompat.ActionPause);

            mMediaSession.SetPlaybackState(mStateBuilder.Build());

            // MySessionCallback() has methods that handle callbacks from a media controller
            mMediaSession.SetCallback(new MySessionCallback());

            // Set the session's token so that client activities can communicate with it.
            SessionToken = mMediaSession.SessionToken;
        }
Ejemplo n.º 7
0
 private void UnregisterMediaSessionCompat()
 {
     try {
         mediaSessionCompat.Dispose();
         mediaSessionCompat = null;
     } catch (Exception ex) {
         Console.WriteLine(ex);
     }
 }
 public MediaNotificationManagerImplementation(Context appliactionContext, MediaSessionCompat.Token sessionToken, Type serviceType)
 {
     _sessionToken = sessionToken;
     _appliactionContext = appliactionContext;
     _intent = new Intent(_appliactionContext, serviceType);
     var mainActivity =
         _appliactionContext.PackageManager.GetLaunchIntentForPackage(_appliactionContext.PackageName);
     _pendingIntent = PendingIntent.GetActivity(_appliactionContext, 0, mainActivity,
         PendingIntentFlags.UpdateCurrent);
 }
Ejemplo n.º 9
0
        protected virtual void PrepareMediaSession()
        {
            MediaSession = new MediaSessionCompat(this, nameof(MediaBrowserService));
            MediaSession.SetSessionActivity(SessionActivityPendingIntent);
            MediaSession.Active = true;

            SessionToken = MediaSession.SessionToken;

            MediaSession.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons |
                                  MediaSessionCompat.FlagHandlesTransportControls);
        }
Ejemplo n.º 10
0
        public RadioStationMediaSession(Context context)
        {
            var intent        = new Intent(context, typeof(MainActivity));
            var pendingIntent = PendingIntent.GetActivity(context, 0, intent, 0);
            var componentName = new ComponentName(context.PackageName, new RadioStationBroadcastReceiver().ComponentName);

            _session = new MediaSessionCompat(context, "wzxv.app", componentName, pendingIntent)
            {
                Active = true
            };
            _session.SetCallback(new MediaSessionCallback(context));
            _session.SetFlags((int)(MediaSessionFlags.HandlesMediaButtons | MediaSessionFlags.HandlesTransportControls));
        }
Ejemplo n.º 11
0
        public RadioStationMediaSession(Context context)
        {
            var intent        = new Intent(context, typeof(Android.App.Activity));
            var pendingIntent = PendingIntent.GetActivity(context, 0, intent, 0);
            var componentName = new ComponentName(context.PackageName, new RadioStationBroadcastReceiver().ComponentName);

            _session    = new MediaSessionCompat(context, "wzxv.app", componentName, pendingIntent);
            _controller = new MediaControllerCompat(context, _session.SessionToken);

            _session.SetCallback(new MediaSessionCallback(context));
            _session.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
            _session.Active = true;
        }
 internal void Release()
 {
     try
     {
         mediaSessionCompat.Release();
         mediaSessionCompat.Dispose();
         mediaSessionCompat = null;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
 internal void Release()
 {
     try
     {
         mediaSessionCompat.Release();
         mediaSessionCompat.Dispose();
         mediaSessionCompat = null;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex);
     }
 }
Ejemplo n.º 14
0
 private void UnregisterMediaSessionCompat()
 {
     try
     {
         if (_mediaSessionCompat != null)
         {
             _mediaSessionCompat.Dispose();
             _mediaSessionCompat = null;
         }
     }
     catch (Exception e)
     {
         System.Diagnostics.Debug.WriteLine(e);
     }
 }
Ejemplo n.º 15
0
        public override void OnCreate()
        {
            base.OnCreate();
            Shared = this;
            NativeAudioPlayer.NativeInit(this);
            PlaybackManager.Shared.Init();
            Session      = new MediaSessionCompat(this, "MusicService");
            SessionToken = Session.SessionToken;
            Session.SetCallback(sessionCallback = new MediaSessionCallback());
            Session.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons |
                             MediaSessionCompat.FlagHandlesTransportControls);
            var context = ApplicationContext;
            var intent  = new Intent(ApplicationContext, typeof(NowPlayingActivity));
            var pi      = PendingIntent.GetActivity(context, 99, intent, PendingIntentFlags.UpdateCurrent);

            Session.SetSessionActivity(pi);

            sessionExtras = new Bundle();

            //		CarHelper.setSlotReservationFlags(mSessionExtras, true, true, true);
            //        WearHelper.setSlotReservationFlags(mSessionExtras, true, true);
            //        WearHelper.setUseBackgroundFromTheme(mSessionExtras, true);

            Session.SetExtras(sessionExtras);


            try
            {
                MediaNotificationManager = new MediaNotificationManager(this);
            }
            catch (Exception ex)
            {
                LogManager.Shared.Report(ex);
                throw ex;
            }

            //VideoCastManager.getInstance().addVideoCastConsumer(mCastConsumer);
            mediaRouter = Android.Support.V7.Media.MediaRouter.GetInstance(ApplicationContext);

            //registerCarConnectionReceiver();
            Managers.NotificationManager.Shared.PlaybackStateChanged += PlaybackStateChanged;
        }
Ejemplo n.º 16
0
        private void InitializeMediaSession()
        {
            try
            {
                if (_mediaSessionCompat == null)
                {
                    Intent        intent        = new Intent(ApplicationContext, typeof(MainActivity));
                    PendingIntent pendingIntent = PendingIntent.GetActivity(ApplicationContext, 0, intent, 0);

                    _remoteComponentName   = new ComponentName(PackageName, new AudioControlsBroadcastReceiver().ComponentName);
                    _mediaSessionCompat    = new MediaSessionCompat(ApplicationContext, "VinylScratch", _remoteComponentName, pendingIntent);
                    _mediaControllerCompat = new MediaControllerCompat(ApplicationContext, _mediaSessionCompat.SessionToken);
                }

                _mediaSessionCompat.Active = true;
                _mediaSessionCompat.SetCallback(new AudioServiceCallback((AudioServiceBinder)_binder));
                _mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e);
            }
        }
Ejemplo n.º 17
0
        private void CreateMediaSession()
        {
            mediaSessionCompatCallback = new MediaSessionCompatCallbacks(this);

            mediaSessionCompat = new MediaSessionCompat(context, channelId);

            Android.Support.V4.Media.MediaMetadataCompat.Builder mediaMetadataCompat = new Android.Support.V4.Media.MediaMetadataCompat.Builder();
            mediaMetadataCompat.PutString(Android.Support.V4.Media.MediaMetadataCompat.MetadataKeyArtist, AppResources.UnknownArtist);
            mediaMetadataCompat.PutString(Android.Support.V4.Media.MediaMetadataCompat.MetadataKeyTitle, AppResources.UnknownTitle);
            mediaSessionCompat.SetMetadata(mediaMetadataCompat.Build());
            mediaSessionCompat.SetMediaButtonReceiver(PendingIntent.GetBroadcast(context, 5, mediaButtonReceiverIntent, PendingIntentFlags.CancelCurrent)); //TODO: Not working

            playbackStateCompat = new PlaybackStateCompat.Builder().SetActions(PlaybackStateCompat.ActionStop | PlaybackStateCompat.ActionPlay | PlaybackStateCompat.ActionPause | PlaybackStateCompat.ActionPlayPause | PlaybackStateCompat.ActionSkipToNext | PlaybackStateCompat.ActionSkipToPrevious)
                                  .SetState(PlaybackStateCompat.StateBuffering, PlaybackStateCompat.PlaybackPositionUnknown, 0)
                                  .Build();

            mediaPlayer = MediaPlayer.Create(context, Resource.Raw.silence);
            mediaPlayer.Start();

            mediaSessionCompat.SetPlaybackState(playbackStateCompat);
            mediaSessionCompat.SetCallback(mediaSessionCompatCallback);

            mediaSessionCompat.Active = true;
        }
Ejemplo n.º 18
0
 public BrowserService(MediaSessionCompat session)
 {
     mediaSession = session;
 }
Ejemplo n.º 19
0
        private void CreateNoti()
        {
            try
            {
                BigViews   = new RemoteViews(PackageName, Resource.Layout.CustomNotificationLayout);
                SmallViews = new RemoteViews(PackageName, Resource.Layout.CustomNotificationSmallLayout);

                Intent notificationIntent = new Intent(this, typeof(SplashScreenActivity));
                notificationIntent.SetAction(Intent.ActionMain);
                notificationIntent.AddCategory(Intent.CategoryLauncher);
                notificationIntent.PutExtra("isnoti", true);
                PendingIntent pendingIntent = PendingIntent.GetActivity(this, 0, notificationIntent, PendingIntentFlags.UpdateCurrent);

                Intent previousIntent = new Intent(this, typeof(PlayerService));
                previousIntent.SetAction(ActionRewind);
                PendingIntent ppreviousIntent = PendingIntent.GetService(this, 0, previousIntent, 0);

                Intent playIntent = new Intent(this, typeof(PlayerService));
                playIntent.SetAction(ActionToggle);
                PendingIntent pplayIntent = PendingIntent.GetService(this, 0, playIntent, 0);

                Intent nextIntent = new Intent(this, typeof(PlayerService));
                nextIntent.SetAction(ActionSkip);
                PendingIntent pnextIntent = PendingIntent.GetService(this, 0, nextIntent, 0);

                Intent closeIntent = new Intent(this, typeof(PlayerService));
                closeIntent.SetAction(ActionStop);
                PendingIntent pcloseIntent = PendingIntent.GetService(this, 0, closeIntent, 0);

                Notification = new NotificationCompat.Builder(this, NotificationChannelId)
                               .SetLargeIcon(BitmapFactory.DecodeResource(Resources, Resource.Mipmap.icon))
                               .SetContentTitle(AppSettings.ApplicationName)
                               .SetPriority((int)NotificationPriority.Max)
                               .SetContentIntent(pendingIntent)
                               .SetSmallIcon(Resource.Drawable.icon_notification)
                               .SetTicker(Constant.ArrayListPlay[Constant.PlayPos]?.Title)
                               .SetChannelId(NotificationChannelId)
                               .SetOngoing(true)
                               .SetAutoCancel(true)
                               .SetOnlyAlertOnce(true);

                NotificationChannel mChannel;
                if (Build.VERSION.SdkInt >= BuildVersionCodes.O)
                {
                    NotificationImportance importance = NotificationImportance.Low;
                    mChannel = new NotificationChannel(NotificationChannelId, AppSettings.ApplicationName, importance);
                    MNotificationManager.CreateNotificationChannel(mChannel);

                    MediaSessionCompat mMediaSession = new MediaSessionCompat(Application.Context, AppSettings.ApplicationName);
                    mMediaSession.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);

                    Notification.SetStyle(new Android.Support.V4.Media.App.NotificationCompat.MediaStyle()
                                          .SetMediaSession(mMediaSession.SessionToken).SetShowCancelButton(true)
                                          .SetShowActionsInCompactView(0, 1, 2)
                                          .SetCancelButtonIntent(MediaButtonReceiver.BuildMediaButtonPendingIntent(Application.Context, PlaybackStateCompat.ActionStop)))
                    .AddAction(new NotificationCompat.Action(Resource.Xml.ic_skip_previous, "Previous", ppreviousIntent))
                    .AddAction(new NotificationCompat.Action(Resource.Xml.ic_pause, "Pause", pplayIntent))
                    .AddAction(new NotificationCompat.Action(Resource.Xml.ic_skip_next, "Next", pnextIntent))
                    .AddAction(new NotificationCompat.Action(Resource.Drawable.ic_action_close, "Close", pcloseIntent));
                }
                else
                {
                    string songName   = Methods.FunString.DecodeString(Constant.ArrayListPlay[Constant.PlayPos]?.Title);
                    string genresName = Methods.FunString.DecodeString(Constant.ArrayListPlay[Constant.PlayPos]?.CategoryName) + " " + Application.Context.Resources.GetString(Resource.String.Lbl_Music);

                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_play, pplayIntent);
                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_next, pnextIntent);
                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_prev, ppreviousIntent);
                    BigViews.SetOnClickPendingIntent(Resource.Id.imageView_noti_close, pcloseIntent);
                    SmallViews.SetOnClickPendingIntent(Resource.Id.status_bar_collapse, pcloseIntent);

                    BigViews.SetImageViewResource(Resource.Id.imageView_noti_play, Android.Resource.Drawable.IcMediaPause);
                    BigViews.SetTextViewText(Resource.Id.textView_noti_name, songName);
                    SmallViews.SetTextViewText(Resource.Id.status_bar_track_name, songName);
                    BigViews.SetTextViewText(Resource.Id.textView_noti_artist, genresName);
                    SmallViews.SetTextViewText(Resource.Id.status_bar_artist_name, genresName);
                    BigViews.SetImageViewResource(Resource.Id.imageView_noti, Resource.Mipmap.icon);
                    SmallViews.SetImageViewResource(Resource.Id.status_bar_album_art, Resource.Mipmap.icon);
                    Notification.SetCustomContentView(SmallViews).SetCustomBigContentView(BigViews);
                }

                ShowNotification();
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
 public QueueNavigator(MediaSessionCompat mediaSession, int maxQueueSize) : base(mediaSession, maxQueueSize)
 {
 }
 private void UnregisterMediaSessionCompat ()
 {
     try
     {
         if(mediaSessionCompat != null)
         {
             mediaSessionCompat.Dispose();
             mediaSessionCompat = null;
         }
     } catch (Exception ex) {
         Console.WriteLine (ex);
     }
 }
        /// <summary>
        /// Will register for the remote control client commands in audio manager
        /// </summary>
        private void InitMediaSession()
        {
            try {
                if (mediaSessionCompat == null) {
                    Intent nIntent = new Intent(ApplicationContext, typeof(MainActivity));
                    PendingIntent pIntent = PendingIntent.GetActivity(ApplicationContext, 0, nIntent, 0);

                    remoteComponentName = new ComponentName (PackageName, new RemoteControlBroadcastReceiver ().ComponentName);

                    mediaSessionCompat = new MediaSessionCompat (ApplicationContext, "XamarinStreamingAudio", remoteComponentName, pIntent);
                    mediaControllerCompat = new MediaControllerCompat(ApplicationContext, mediaSessionCompat.SessionToken);
                }

                mediaSessionCompat.Active = true;
                mediaSessionCompat.SetCallback (new MediaSessionCallback((MediaPlayerServiceBinder)binder));

                mediaSessionCompat.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons | MediaSessionCompat.FlagHandlesTransportControls);
            } 
            catch (Exception ex) {
                Console.WriteLine (ex);
            }
        }
Ejemplo n.º 23
0
        public override void OnCreate()
        {
            base.OnCreate();
            LogHelper.Debug(Tag, "onCreate");

            musicProvider = new MusicProvider();

            var context = ApplicationContext;

            var hasReadExternalStoragePermission = ActivityCompat.CheckSelfPermission(context, Manifest.Permission.ReadExternalStorage);

            if (hasReadExternalStoragePermission == Permission.Granted)
            {
                musicProvider.RetrieveMediaAsync(context, null);
            }
            else
            {
                var msg = Resources.GetString(Resource.String.permission_denied_msg, "READ_EXTERNAL_STORAGE");
                Toast.MakeText(context, msg, ToastLength.Short).Show();
            }

            packageValidator = new PackageValidator(this);

            lightOrganProcessor = new LightOrganProcessor();
            lightOrganProcessor.LightOrganDataUpdated += (s, e) =>
            {
                OnLightOrganDataUpdated(e.Data);
            };

            var queueManager = new QueueManager(musicProvider, Resources,
                                                new QueueManager.MetadataUpdateListener
            {
                OnMetadataChanged = (metadata) =>
                {
                    session.SetMetadata(metadata);
                },

                OnMetadataRetrieveError = () =>
                {
                    playbackManager.UpdatePlaybackState(Resources.GetString(Resource.String.no_metadata_msg));
                },

                OnCurrentQueueIndexUpdated = (queueIndex) =>
                {
                    playbackManager.HandlePlayRequest();
                },

                OnQueueUpdated = (title, newQueue) =>
                {
                    session.SetQueue(newQueue);
                    session.SetQueueTitle(title);
                }
            });

            var hasRecordAudioPermission = ActivityCompat.CheckSelfPermission(context, Manifest.Permission.RecordAudio);

            if (hasRecordAudioPermission != Permission.Granted)
            {
                var msg = Resources.GetString(Resource.String.permission_denied_msg, "RECORD_AUDIO");
                Toast.MakeText(context, msg, ToastLength.Short).Show();
            }

            var playback = new LocalPlayback(this, musicProvider, hasRecordAudioPermission == Permission.Granted);

            playbackManager = new PlaybackManager(this, Resources, musicProvider, queueManager, playback);

            // Start a new MediaSession
            session      = new MediaSessionCompat(this, "MusicService");
            SessionToken = session.SessionToken;
            session.SetCallback(playbackManager.GetMediaSessionCallback());
            session.SetFlags(MediaSessionCompat.FlagHandlesMediaButtons |
                             MediaSessionCompat.FlagHandlesTransportControls);

            var intent = new Intent(context, typeof(MainActivity));
            var pi     = PendingIntent.GetActivity(context, 99 /*request code*/,
                                                   intent, PendingIntentFlags.UpdateCurrent);

            session.SetSessionActivity(pi);

            playbackManager.UpdatePlaybackState(null);

            try
            {
                mediaNotificationManager = new MediaNotificationManager(this);
            }
            catch (Exception e)
            {
                throw new Exception("Could not create a MediaNotificationManager", e);
            }
        }
Ejemplo n.º 24
0
 void CreateMediaSession()
 {
     mediaSession = new MediaSessionCompat(this, "CloudStream 2");
     mediaSession.SetFlags((int)(MediaSessionFlags.HandlesMediaButtons | MediaSessionFlags.HandlesTransportControls));
     mediaSession.SetCallback(new MediaSessionCallback());
 }
 public QueueNavigator(MediaSessionCompat mediaSession) : base(mediaSession)
 {
     this.mediaSession = mediaSession;
 }
Ejemplo n.º 26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource   = Resource.Layout.Toolbar;

            base.OnCreate(savedInstanceState);
            //    Download("Songs", null);
            // Set Status Bar Color
            Window.AddFlags(WindowManagerFlags.DrawsSystemBarBackgrounds);
            // Window.SetStatusBarColor(Android.Graphics.Color.Black);
            notificationManager = NotificationManagerCompat.From(this);



            mediaSession = new MediaSessionCompat(this, "tag");

            // CarouselViewRenderer.();

            CachedImageRenderer.Init(true);
            //  RegisterReceiver(savedInstanceState, new IntentFilter("com.companyname.IncomingCall"));

            //// FFImageLoading
            //CachedImageRenderer.Init();

            //// AudioService setup
            Instance = this;
            System.Threading.Tasks.Task.Run(() =>
            {
                Intent AudioServiceIntent = new Intent(this, typeof(AudioService));
                this.StartService(AudioServiceIntent);
                _connection = new AudioServiceConnection(this);
                bool binded = BindService(AudioServiceIntent, _connection, Bind.AutoCreate);
            });


            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

            global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
            Plugin.CurrentActivity.CrossCurrentActivity.Current.Init(this, savedInstanceState);

            //// FlowListView
            FlowListView.Init();

            Rg.Plugins.Popup.Popup.Init(this, savedInstanceState);

            if (ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadExternalStorage) != Permission.Granted || ContextCompat.CheckSelfPermission(this, Manifest.Permission.ReadPhoneState) != Permission.Granted)
            {
                // We have permission, go ahead and use the camera.
                if (ActivityCompat.ShouldShowRequestPermissionRationale(activity: this, Manifest.Permission.ReadExternalStorage) ||
                    ActivityCompat.ShouldShowRequestPermissionRationale(activity: this, Manifest.Permission.ReadPhoneState))
                {
                    ActivityCompat.RequestPermissions(activity: this, new String[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadPhoneState }, STORAGE_PERMISSION_CODE);
                }

                else
                {
                    ActivityCompat.RequestPermissions(activity: this, new String[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadPhoneState }, STORAGE_PERMISSION_CODE);
                }
            }
            else
            {
                if (ActivityCompat.ShouldShowRequestPermissionRationale(activity: this, Manifest.Permission.ReadExternalStorage) ||
                    ActivityCompat.ShouldShowRequestPermissionRationale(activity: this, Manifest.Permission.ReadPhoneState))
                {
                    ActivityCompat.RequestPermissions(activity: this, new String[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.WriteExternalStorage, Manifest.Permission.ReadExternalStorage }, STORAGE_PERMISSION_CODE);
                }
                else
                {
                    ActivityCompat.RequestPermissions(activity: this, new String[] { Manifest.Permission.ReadExternalStorage, Manifest.Permission.ReadPhoneState }, STORAGE_PERMISSION_CODE);
                }
            }
            LoadApplication(new App());
        }