この問題に関する多くのドキュメントを読んでいますが、私は何の答えも見ていません。Xamarin IOS:インターネットからmp3を再生することができません
Groove音楽サービスからmp3サンプル音楽を再生するXamarinフォームアプリがあります。
Androidの場合、毎回問題なく動作します。 Iosでは、サウンドを再生できません。私はURLを取得し、それが耳何もすることはできません私はこの問題はSWIFTを使用している人々のためにも発生した参照
(私は地元のmp3を再生することができました):How to play MP3 From URL in iOS
私はまた、Xamarinフォーラムにいくつかのexempleを見つけましたしかし、何の音もない:
パブリッククラスAudioService:https://forums.xamarin.com/discussion/19883/how-do-i-get-the-avplayer-to-play-an-mp3-from-a-remote-url
ここで私が使用したコードではありませんiAUDIOの { 保護された文字列filename = String.Emptyをは。 AVPlayer Playerを保護しました。
public bool IsPlaying { get; private set; }
public void Init(string fileName)
{
//FileName = fileName;
string second = "http://progdownload.zune.net/145/119/034/170/audio.mp3?rid=0b80911a-ba3b-42ec-b17f-c242ba087024-s4-nl-BE-music-asset-location";
FileName = second;
QueueFile();
}
public async void PlayStream(string uri)
{
Init(uri);
System.Diagnostics.Debug.WriteLine("Enter in function");
Player.Play();
System.Diagnostics.Debug.WriteLine("Play sound");
System.Diagnostics.Debug.WriteLine(FileName);
IsPlaying = true;
System.Diagnostics.Debug.WriteLine(IsPlaying);
}
public void Pause()
{
IsPlaying = false;
Player.Pause();
}
public void Stop()
{
IsPlaying = false;
if (Player == null) return;
Player.Dispose();
Player = null;
}
public bool HasFile
{
get { return Player != null; }
}
private void QueueFile()
{
if (string.IsNullOrWhiteSpace(FileName))
{
throw new Exception("No file specified to play");
}
using (var url = NSUrl.FromString(FileName))
{
var test = AVAsset.FromUrl(url);
var playerItem = AVPlayerItem.FromAsset(test);
// if Player is null, we're creating a new instance and seeking to the spot required
// otherwise we simply resume from where we left off.
if (Player == null)
{
Player = AVPlayer.FromPlayerItem(playerItem);
if (Player == null)
{
// todo: what should we do if the file doesn't exist?
return;
}
}
}
}}
(iAUDIOのがちょうどplaystreamを実装し、停止)
あなたがURLをクリックすると、お使いのブラウザは http://progdownload.zune.net/145/119/034/170/audio.mp3?rid=0b80911a-ba3b-42ec-b17f-c242ba087024-s4-nl-BE-music-asset-location
音楽を再生することができますがいずれかのインターネットからmp3を再生することができたい
私にとっては不思議な出来事、ありがとうMr @Thando Toto –