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