1.在MainActivity上初始化CrossMediaManager
protected override void OnCreate(Bundle savedInstanceState)
{
TabLayoutResource = Resource.Layout.Tabbar;
ToolbarResource = Resource.Layout.Toolbar;
base.OnCreate(savedInstanceState);
Xamarin.Essentials.Platform.Init(this, savedInstanceState);
global::Xamarin.Forms.Forms.Init(this, savedInstanceState);
CrossMediaManager.Current.Init(this);
LoadApplication(new App());
}
2. 点击按钮执行播放功能
var mediaItem = await CrossMediaManager.Current.Play("http://tasfiaradio.servemp3.com:8000/tasfia1");
与
IMediaItem mediaFile = await CrossMediaManager.Current.Extractor.CreateMediaItem("http://tasfiaradio.servemp3.com:8000/tasfia1");
var mediaItem = await CrossMediaManager.Current.Play(mediaFile);
预期行为
听到声音
配置
Plugin.MediaManager:0.9.7 Xamarin.Forms:4.5.0.495