/// <summary>
        /// On create simply detect some of our managers
        /// </summary>
        public override void OnCreate()
        {
            base.OnCreate();
            //Find our audio and notificaton managers
            audioManager = (AudioManager)GetSystemService(AudioService);
            wifiManager = (WifiManager)GetSystemService(WifiService);

			remoteComponentName = new ComponentName(PackageName, new RemoteControlBroadcastReceiver().ComponentName);
        }
Beispiel #2
1
        public override void OnCreate ()
        {
            base.OnCreate ();

            _episodeProgressUpdateTimer = new Timer (
                o => UpdateEpisodeCurrentTimeIfPlaying(),
                null,
                0,
                EPISODE_CURRENT_TIME_UPDATE_INTERVAL
            );

            // Find our audio and notificaton managers
            _audioManager = (AudioManager)GetSystemService (AudioService);
            _wifiManager = (WifiManager)GetSystemService (WifiService);
        }
        public HapticFeedback_Android()
        {
            try {
                am = (AudioManager)global::Android.App.Application.Context.GetSystemService (Context.AudioService);
            } catch (Exception ex) {
                try {
                    var msg = LogMessage.FromException (ex, "Error initializing AudioManager! ", typeof(HapticFeedback_Android), "(constructor)");
                    PortableLogging.Instance.AppendMessages (new [] { msg });
                } catch {
                }
            }

            try {
                v = (Vibrator)global::Android.App.Application.Context.GetSystemService (Context.VibratorService);
            } catch (Exception ex) {
                try {
                    var msg = LogMessage.FromException (ex, "Error initializing Vibrator! ", typeof(HapticFeedback_Android), "(constructor)");
                    PortableLogging.Instance.AppendMessages (new [] { msg });
                } catch {
                }
            }
            if (v != null && !v.HasVibrator) {
                try {
                    var msg = LogMessage.FromException (new Exception (), "Android device does not have vibrator.", typeof(HapticFeedback_Android), "(constructor)");
                    PortableLogging.Instance.AppendMessages (new [] { msg });
                } catch {
                }
            }
        }
 /// <summary>
 /// On create simply detect some of our managers
 /// </summary>
 public override void OnCreate()
 {
     base.OnCreate();
     //Find our audio and notificaton managers
     audioManager = (AudioManager)GetSystemService(AudioService);
     wifiManager = (WifiManager)GetSystemService(WifiService);
 }
Beispiel #5
0
        public static void Initialize(Activity activity)
        {
            audioManager = (AudioManager)activity.GetSystemService(Context.AudioService);

            mediaPlayer = MediaPlayer.Create(activity.ApplicationContext, Resource.Raw.Message);

            notificationManager = (NotificationManager)activity.GetSystemService(Context.NotificationService);
            vibrator = (Vibrator)activity.GetSystemService(Context.VibratorService);

            //context = activity.ApplicationContext;
            context = activity;

            isAlertsEnabled = true;
            isProgressEnabled = true;
        }
		public override void OnCreate ()
		{
			base.OnCreate ();

			audio_manager = (AudioManager)GetSystemService (AudioService);

			//set the original volume and max volume variables to the phone's current and max volume levels
			orig_volume = audio_manager.GetStreamVolume (Android.Media.Stream.Ring);
			max_volume = audio_manager.GetStreamMaxVolume (Android.Media.Stream.Ring);

			//set the sound for the alarm to the phone's alarm tone
			alarm_sound = RingtoneManager.GetDefaultUri (RingtoneType.Alarm);

			media_player = new MediaPlayer ();
		}
        public void Initialize()
        {
            audioManager = (Android.Media.AudioManager)Application.Context.GetSystemService(Context.AudioService);
            audioManager.RegisterMediaButtonEventReceiver(PendingIntent.GetBroadcast(Application.Context, 0, new Intent("music-controls-media-button"), PendingIntentFlags.UpdateCurrent));

            receiver     = new XamarinAudioManagerBroadcastReceiver();
            intentFilter = new IntentFilter();
            foreach (var intent in intents)
            {
                intentFilter.AddAction(intent);
            }

            Application.Context.RegisterReceiver(receiver, intentFilter);
            throw new NotImplementedException();
        }
		public Playback(MusicService service, MusicProvider musicProvider) {
			this.service = service;
			this.musicProvider = musicProvider;
			audioManager = (AudioManager) service.GetSystemService(Context.AudioService);
			wifiLock = ((WifiManager) service.GetSystemService(Context.WifiService))
				.CreateWifiLock(WifiMode.Full, "sample_lock");
			mAudioNoisyReceiver.OnReceiveImpl = (context, intent) => {
				if (AudioManager.ActionAudioBecomingNoisy == intent.Action) {
					LogHelper.Debug(Tag, "Headphones disconnected.");
					if (IsPlaying) {
						var i = new Intent(context, typeof(MusicService));
						i.SetAction(MusicService.ActionCmd);
						i.PutExtra(MusicService.CmdName, MusicService.CmdPause);
						service.StartService(i);
					}
				}
			};
		}
		/// <summary>
		/// Raised, when the activity is created.
		/// </summary>
		/// <param name="bundle">Bundle with cartridge and restore flag.</param>
		protected override void OnCreate (Bundle bundle)
		{
			// Set color schema for activity
			Main.SetTheme(this);

			base.OnCreate (bundle);

			// Load content of activity
			SetContentView (Resource.Layout.GameControllerScreen);

			// Get main layout to replace with fragments
			var layoutMain = FindViewById<LinearLayout> (Resource.Id.layoutMain);

			// Get data from intent
			Intent intent = this.Intent;

			string cartFilename = intent.GetStringExtra ("cartridge");
			cartRestore = intent.GetBooleanExtra ("restore", false);

			// Check, if cartridge files exists, and if yes, create a new cartridge object
			if (File.Exists (cartFilename)) {
				cartridge = new Cartridge(cartFilename);
			}

			// If cartridge object don't exist, than close activity
			if (cartridge == null)
				Finish ();

			audioManager = (AudioManager)GetSystemService(Context.AudioService);
			vibrator = (Vibrator)GetSystemService(Context.VibratorService);

			// Create CheckLocation
			GameCheckLocation checkLocation = new GameCheckLocation();

			// Show CheckLocation
			var ft = SupportFragmentManager.BeginTransaction ();
			ft.SetBreadCrumbTitle (cartridge.Name);
			ft.SetTransition (global::Android.Support.V4.App.FragmentTransaction.TransitNone);
			ft.Replace (Resource.Id.fragment, checkLocation);
			ft.Commit ();
		}
Beispiel #10
0
 public RingerModeIntentReceiver(AudioManager audioManager)
 {
     this.audioManager = audioManager;
 }
        public void InitMusicPlayer()
        {
            _appSettingsHelper = new AppSettingsHelper();
            _player = new MediaPlayer();
            _wifiLock = ((WifiManager)GetSystemService(WifiService)).CreateWifiLock(WifiMode.Full, "playerLock");

            _player.SetWakeMode(ApplicationContext, WakeLockFlags.Partial);
            _player.SetAudioStreamType(Stream.Music);
            _player.SetOnPreparedListener(this);
            _player.SetOnCompletionListener(this);
            _player.SetOnErrorListener(this);

            _audioManager = (AudioManager) GetSystemService(AudioService);

            _mediaButtonReceiverComponent = new ComponentName(ApplicationContext,
                Class.FromType(typeof (HeadsetButtonsReceiver)));
            _audioManager.RegisterMediaButtonEventReceiver(_mediaButtonReceiverComponent);
        }
        /// <summary>
        /// OnCreate() detects some of our managers
        /// </summary>
        public override void OnCreate()
        {
            Log.Debug(TAG, "StreamingService.OnCreate()");
            base.OnCreate();

            audioManager = (AudioManager)GetSystemService(AudioService);
            wifiManager = (WifiManager)GetSystemService(WifiService);
            headphonesUnpluggedReceiver = new MusicBroadcastReceiver();
            if (Android.OS.Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop)
            {
                mediaSession = new MediaSession(this, "KVMRMediaSession");

                mediaCallback = new MediaSessionCallback();
                mediaCallback.OnPlayImpl = () =>
                {
                    if (IsPlaying)
                    {
                        Log.Debug(TAG, "MediaCallback stop playing");
                        Stop();
                        MessagingCenter.Send<PlayerStoppedMessage>(new PlayerStoppedMessage(), "PlayerStopped");
                    }
                    else
                    {
                        Log.Debug(TAG, "MediaCallback start playing. source: " + source ?? "null");
                        Play(source);
                        MessagingCenter.Send(new RemoteControlPlayMessage(), "RemoteControlPlay");
                    }
                };

                mediaSession.SetCallback(mediaCallback);
                mediaSession.SetFlags(MediaSessionFlags.HandlesMediaButtons |
                    MediaSessionFlags.HandlesTransportControls);

                PlaybackState state = new PlaybackState.Builder()
                    .SetActions(PlaybackState.ActionPlay | PlaybackState.ActionPlayPause
                                          | PlaybackState.ActionPause | PlaybackState.ActionStop)
                    .Build();
                mediaSession.SetPlaybackState(state);
                mediaSession.Active = true;
            }
        }