本文整理汇总了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.
};
}
示例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 ();
}
}
示例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.
};
}
示例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);
}
示例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);
}