hudec117 / Mpv.NET-lib-

.NET embeddable video/media player based on mpv for WinForms and WPF
MIT License
138 stars 36 forks source link

MediaLoaded event delays when loading multiple files #8

Closed mysteryx93 closed 5 years ago

mysteryx93 commented 5 years ago

If I'm opening up 20 audio files at the same time, the first 8 files open right away, then each additional file gets the MediaLoaded event fired one per second, so it takes 12 seconds until the players are properly initiated. However, the file position shows they all started playing right away, but MediaLoaded is delaying.

What could be causing such a delay? Playback is working but it's screwing up the UI.

To reproduce, use MpvPlayerUI like this. Bind it to a list of source files and it should display the list in separate players.

<ScrollViewer HorizontalAlignment="Right" Width="302">
    <ItemsControl ItemsSource="{Binding Playlist.Files}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <MpvPlayerUI:MpvMediaPlayer ui:UIProperties.IsLoopVisible="False">
                    <MpvPlayerUI:MpvMediaPlayerHost Source="{Binding FullPath, Mode=TwoWay}" Loop="True" />
                </MpvPlayerUI:MpvMediaPlayer>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
</ScrollViewer>
mysteryx93 commented 5 years ago

After looking into the code, this bug is related to MPV itself so not much you can do on your side. I have submitted a ticket here