如何使用MediaPlayBacklist实现无差距播放? (UWP,Winui 3)

发布于 2025-02-12 11:28:34 字数 709 浏览 0 评论 0 原文

我正在尝试实施无间隙媒体播放器。我创建一个 MediaPlayBackitem '并将它们添加到 MediaPlayBackList 。媒体播放项目是为文件创建的,使用 MediaSource.CreateFromuri()上传在服务器上。

到目前为止,一切都很好,但是当我演奏媒体时,从一个项目到另一个项目的过渡时,有一个明显的暂停。我想避免这种情况。

根据文档:

MediaPlayBacklist中的项目使用无缝隙播放。

但是,差距在那里。我试图设置“ MediaPlayBacklist.maxprefetchtime”,但它什么也没做。

有什么方法可以使用MediaPlayBacklist实现无脱节的播放?

I am trying to implement gapless media player. I create a list of MediaPlaybackItem's and add them to an instance of MediaPlaybackList. The media playback items are created for files, uploaded on a server, using MediaSource.CreateFromUri().

So far so good, but when I play the media, there is a clearly audible pause when playing transitions from one item to another. I want to avoid this.

According to the documentation:

Items in a MediaPlaybackList are rendered using gapless playback.

However, the gap is there. I tried to set 'MediaPlaybackList.MaxPrefetchTime' but it did nothing.

Is there a way I can implement gapless playing using MediaPlaybackList?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

鲜肉鲜肉永远不皱 2025-02-19 11:28:34

实际上,差距是由于从URI源打开下一个 MediaPlayBackitem 的流时引起的。

我要做的是在启动播放器之前在每个媒体播放项目上调用 openasync()

foreach (var item in mediaItems)
{
    _ = item.Source.OpenAsync();
}

这是一个过度简化的示例,我不等待异步方法,因此不会捕获潜在的错误。由于我不想在打开歌曲时延迟延迟,因此最好的方法是列出所有异步方法,并在单独的任务中等待它们使用“ task.whenall”。

Indeed, the gap was caused because of the delay while opening the stream of the next MediaPlaybackItem from the Uri source.

What I did is to call OpenAsync() on each media playback item before starting the player:

foreach (var item in mediaItems)
{
    _ = item.Source.OpenAsync();
}

This is a oversimplified example, where I do not await the async methods and therefore do not trap potential errors. Since I do not want to have a delay while the songs are opened, the best way would be to make a list of all async methods, and wait for them using 'Task.WhenAll' in a separate task.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文