Ios 使用AVQueuePlayer的属性
我正试图在Xamarin.iOS中为一个AVQueuePlayer添加一个采访列表,这对我很有用。但是,我确实需要能够从用于创建AVPlayerItems的类中获取一些属性 我的面试课:Ios 使用AVQueuePlayer的属性,ios,xamarin.ios,xamarin,avplayer,avqueueplayer,Ios,Xamarin.ios,Xamarin,Avplayer,Avqueueplayer,我正试图在Xamarin.iOS中为一个AVQueuePlayer添加一个采访列表,这对我很有用。但是,我确实需要能够从用于创建AVPlayerItems的类中获取一些属性 我的面试课: public class Interview { public int Id { get; set; } public Topic Topic { get; set; } public Person Person { get; set; }
public class Interview
{
public int Id { get; set; }
public Topic Topic { get; set; }
public Person Person { get; set; }
public string VideoURL { get; set; }
public int AudioID { get; set; }
public Interview ()
{
}
public Interview (int id, Topic t, Person p, string videoUrl, int audioId)
{
Id = id;
Topic = t;
Person = p;
VideoURL = videoUrl;
AudioID = audioId;
}
我的PlayerClass中有一个方法如下所示:
void AudioPlayWithAVQueuePlayer ()
{
Console.WriteLine ("AVPlayer");
var center = NSNotificationCenter.DefaultCenter;
//int pointer = 0;
List<AVPlayerItem> playeritems = new List<AVPlayerItem>();
foreach (Interview i in appDelegate.currentlyPlaying.Interviews) {
AVAsset _asset;
AVPlayerItem _playerItem;
_asset = AVAsset.FromUrl (new NSUrl ("https://api.soundcloud.com/tracks/" + i.AudioID + "/stream?client_id=clientID&oauth_token=token"));
_playerItem = new AVPlayerItem (_asset);
playeritems.Add (_playerItem);
}
appDelegate.avPlayer = new AVQueuePlayer (playeritems.ToArray());
appDelegate.avPlayer.Play ();
}
}
void AudioPlayWithAVQueuePlayer()
{
Console.WriteLine(“AVPlayer”);
var center=NSNotificationCenter.DefaultCenter;
//int指针=0;
List playeritems=新列表();
foreach(appDelegate.currentlyPlaying.Sessions中的面试i){
AVAsset_资产;
AVPlayerItem_playerItem;
_asset=AVAsset.FromUrl(新NSUrl(“https://api.soundcloud.com/tracks/“+i.AudioID+”/stream?客户端(id=clientID&oauth_-token=token”);
_playerItem=新的AVPlayerItem(_资产);
playeritems.Add(_playerItem);
}
appDelegate.avPlayer=新的AVQueuePlayer(playeritems.ToArray());
appDelegate.avPlayer.Play();
}
}
这将完美地播放我的音频文件(存储在SoundCloud上),但我需要用Interview.Person.PersonName和Interview.Topic.TopicName更新一些标签。在我通过采访中的AudioID创建了AVPlayerItem之后,有什么方法可以访问这些属性吗?
我唯一能找到的是元数据,但我的音频文件不包含任何元数据 不能将任意数据附加到排队的AVPlayerItem对象,因此一种解决方案是以其他方式将任意数据与AVPlayerItem对象关联。例如,如果从一个avurlaste开始生成AVPlayerItem,那么AVPlayerItem有一个
asset
,它(因为它是一个avurlaste)有一个URL
,因此现在我们可以想象一个NSDictionary,其中键是URL,值是相应的访问对象。。这很有道理,而且很容易做到。谢谢。