我正在尝试实施无间隙媒体播放器。我创建一个 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?
发布评论
评论(1)
实际上,差距是由于从URI源打开下一个
MediaPlayBackitem
的流时引起的。我要做的是在启动播放器之前在每个媒体播放项目上调用
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: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.