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


C# MediaPlayer.SetWakeMode方法代码示例

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


在下文中一共展示了MediaPlayer.SetWakeMode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: CreateMediaPlayerIfNeeded

		void CreateMediaPlayerIfNeeded ()
		{
			LogHelper.Debug (Tag, "createMediaPlayerIfNeeded. needed? ", (mediaPlayer==null));
			if (mediaPlayer == null) {
				mediaPlayer = new MediaPlayer ();

				mediaPlayer.SetWakeMode (service.ApplicationContext,
					Android.OS.WakeLockFlags.Partial);

				mediaPlayer.SetOnPreparedListener (this);
				mediaPlayer.SetOnCompletionListener (this);
				mediaPlayer.SetOnErrorListener (this);
				mediaPlayer.SetOnSeekCompleteListener (this);
			} else {
				mediaPlayer.Reset ();
			}
		}
开发者ID:Appercode,项目名称:monodroid-samples,代码行数:17,代码来源:Playback.cs

示例3: 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

示例4: 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

示例5: 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


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