当前位置: 首页>>代码示例>>C#>>正文


C# MediaPlayer.SetAudioStreamType方法代码示例

本文整理汇总了C#中Android.Media.MediaPlayer.SetAudioStreamType方法的典型用法代码示例。如果您正苦于以下问题:C# MediaPlayer.SetAudioStreamType方法的具体用法?C# MediaPlayer.SetAudioStreamType怎么用?C# MediaPlayer.SetAudioStreamType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Android.Media.MediaPlayer的用法示例。


在下文中一共展示了MediaPlayer.SetAudioStreamType方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: IntializePlayer

        private void IntializePlayer()
        {
            player = new MediaPlayer();

            //Tell our player to sream music
            player.SetAudioStreamType(Stream.Music);

            //Wake mode will be partial to keep the CPU still running under lock screen
            player.SetWakeMode(ApplicationContext, WakeLockFlags.Partial);

            //When we have prepared the song start playback
            player.Prepared += (sender, args) => player.Start();

            //When we have reached the end of the song stop ourselves, however you could signal next track here.
            player.Completion += (sender, args) => Stop();

            player.Error += (sender, args) =>
            {
                //playback error
                Console.WriteLine("Error in playback resetting: " + args.What);
                Stop();//this will clean up and reset properly.
            };
        }
开发者ID:helmsb,项目名称:AndroidStreamingAudio,代码行数:23,代码来源:StreamingBackgroundService.cs

示例2: IntializePlayer

        void IntializePlayer ()
        {
            _player = new MediaPlayer ();

            // Tell our player to sream music
            _player.SetAudioStreamType (Stream.Music);

            // Wake mode will be partial to keep the CPU still running under lock screen
            _player.SetWakeMode (ApplicationContext, WakeLockFlags.Partial);

            // When we have prepared the song start playback
            _player.Prepared += (sender, args) => _player.Start ();

            // When we have reached the end of the song stop ourselves, however you could signal next track here.
            _player.Completion += (sender, args) =>
            {
                Stop ();
                CurrentEpisode.CurrentTime = CurrentEpisode.Duration;
                DrunkAudibleApplication.Self.Database.InsertOrReplace (CurrentEpisode);
                if (NextEpisode != null)
                {
                    NextEpisode.CurrentTime = 0;
                    CurrentEpisode = NextEpisode;
                }
            };

            _player.Error += (sender, args) => 
            {
                // playback error
                Log.Debug (DEBUG_TAG, "Error in playback resetting: " + args.What);
                Stop ();//this will clean up and reset properly.
            };
        }
开发者ID:puncsky,项目名称:DrunkAudible,代码行数:33,代码来源:PlayerService.cs

示例3: InitMusicPlayer

        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);
        }
开发者ID:jayharry28,项目名称:Audiotica,代码行数:18,代码来源:AudioPlaybackService.cs

示例4: InitializePlayer

        /// <summary>
        /// Intializes the player.
        /// </summary>
        private void InitializePlayer ()
        {
            mediaPlayer = new MediaPlayer ();

            //Tell our player to sream music
            mediaPlayer.SetAudioStreamType (Stream.Music);

            //Wake mode will be partial to keep the CPU still running under lock screen
            mediaPlayer.SetWakeMode (ApplicationContext, WakeLockFlags.Partial);

            mediaPlayer.SetOnBufferingUpdateListener (this);
            mediaPlayer.SetOnCompletionListener (this);
            mediaPlayer.SetOnErrorListener (this);
            mediaPlayer.SetOnPreparedListener (this);
        }
开发者ID:helmsb,项目名称:AndroidStreamingAudio,代码行数:18,代码来源:MediaPlayerService.cs

示例5: OnCreate

                public override void OnCreate()
                {
                    base.OnCreate();

                    Rock.Mobile.Util.Debug.WriteLine( "AudioService::OnCreate" );

                    Binder = new AudioServiceBinder( this );

                    // prepare our media player
                    MediaPlayer = new MediaPlayer();
                    MediaPlayer.SetAudioStreamType( Stream.Music );
                    MediaPlayer.Stop( );
                }
开发者ID:Higherbound,项目名称:HBMobileApp,代码行数:13,代码来源:NotesListenFragment.cs

示例6: OnCreate

        public override void OnCreate()
        {
            base.OnCreate();
              mediaPlayer = new MediaPlayer();
              mediaPlayer.SetAudioStreamType(Stream.Music);
              mediaPlayer.SetDataSource(StreamAddress);

              mediaPlayer.Prepared += MediaPlayerPrepared;

              mediaSession = new MediaSession(this, PackageName);

              notificationManager = (NotificationManager)GetSystemService(NotificationService);
        }
开发者ID:Machinarius,项目名称:AHFM,代码行数:13,代码来源:PlaybackService.cs

示例7: PlaySound

		void PlaySound (string customSound)
		{
			if (_ringtone != null) {
				return;
			}           

//			_ringtone = RingtoneManager.GetRingtone (Application.Context, sound);
//			_ringtone.Play ();

			try {
				var sound = GetRingtoneUri (customSound);

				_ringtone = new MediaPlayer ();
				_ringtone.SetDataSource (this, sound);

				_ringtone.SetAudioStreamType (Stream.Alarm);

				_ringtone.Looping = true;
				_ringtone.Prepare ();
				_ringtone.Start ();
			} catch {
			}   
		}
开发者ID:foxanna,项目名称:SimpleLocationAlarm,代码行数:23,代码来源:UIWhileRingingIntentService.cs

示例8: InitBeepSound

        void InitBeepSound()
        {
            if(playBeep && mediaPlayer == null)
            {
                VolumeControlStream = Android.Media.Stream.Music;
                mediaPlayer = new MediaPlayer();
                mediaPlayer.SetAudioStreamType(Android.Media.Stream.Music);
                mediaPlayer.SetOnCompletionListener(beepListener);

                var file = Resources.OpenRawResourceFd(BeepResource);
                try{
                    mediaPlayer.SetDataSource(file.FileDescriptor, file.StartOffset, file.Length);

                    file.Close();
                    mediaPlayer.SetVolume(0.1f, 0.1f);
                    mediaPlayer.Prepare();
                }
                catch(Java.IO.IOException e)
                {
                    mediaPlayer = null;
                }
            }
        }
开发者ID:ebeisecker,项目名称:Playpen,代码行数:23,代码来源:BarcodeScanActivity.cs


注:本文中的Android.Media.MediaPlayer.SetAudioStreamType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。