xamarin.android播放音频,xamarin.android

public override void OnActivityCreated (Bundle savedInstanceState)

{

base.OnActivityCreated (savedInstanceState);

StartMedia(source);

}

public void StartMedia(string url_string)

{

player = new MediaPlayer ();

player.SetDataSource (url_string);

//player.Prepare ();

player.Start ();

}

It don't run. don't run, don't listen anything. I have debug but I don't see it though over void StartMedia

StartMedia(mListData[mPosition].stream_url+"?client_id="+clienId);

}

public async void StartMedia(string url_string)

{

player = new MediaPlayer ();

player.SetVolume (100, 100);

player.SetAudioStreamType (Stream.Music);

await player.SetDataSourceAsync(Android.App.Application.Context,Android.Net.Uri.Parse(url_string));

player.PrepareAsync ();

player.Start ();

}

When the audio to play is included as a resource, the method can be used to set up the data source to the audio file and prepare the player for playback automatically.

你可能感兴趣的:(xamarin.android播放音频,xamarin.android)