gpt4 book ai didi

ios - AVQueuePlayer 的属性

转载 作者:行者123 更新时间:2023-11-28 22:09:37 26 4
gpt4 key购买 nike

我正在尝试将采访列表添加到 Xamarin.iOS 中的 AVQueuePlayer,这对我有用。但是,我确实需要能够从我用来创建 AVPlayerItems 的类中获取一些属性

我的面试课:

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 ();
}
}

这将完美播放我的音频文件(存储在 SoundCloud 上),但我需要使用 Interview.Person.PersonName 和 Interview.Topic.TopicName 更新一些标签。在采访中从 AudioID 创建 AVPlayerItem 后,有什么方法可以访问这些属性?我唯一能找到的是元数据,但我的音频文件不包含任何元数据。

最佳答案

您不能将任意数据附加到排队的 AVPlayerItem 对象,因此一种解决方案是以某种其他方式将任意数据与 AVPlayerItem 对象相关联。例如,如果您从一个 AVURLAsset 开始生成您的 AVPlayerItem,那么 AVPlayerItem 有一个 asset,它(因为它是一个 AVURLAsset)有一个 URL,所以现在我们可以想象一个 NSDictionary,其中键是 URL,值是相应的采访对象。

关于ios - AVQueuePlayer 的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23225814/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com