24/7 computer, a problem with the WPF media element, turns black after 3 hours

I have a computer that will run WPF 24/7 and play a playlist of images and videos. When I run my program, everything works fine, but after 2-3 hours the windows of the media element are black.

When I run the program, it takes all the file names in the folder and puts them in a list

 Dim root As String = MediaDir & "media"
    Dim dir As New System.IO.DirectoryInfo(root)
    Dim fileList = dir.GetFiles("*.*", System.IO.SearchOption.AllDirectories)

    Dim fileQuery = From file In fileList _
                    Where file.Extension = ".jpg" _
                    Or file.Extension = ".avi" _
                    Or file.Extension = ".mov" _
                    Order By file.Name _
                    Select file

    For Each file In fileQuery
        listbox1.Items.Add(file.FullName)
    Next
    i = 0
    Media_Org.Source = New Uri(listbox1.Items(i), UriKind.Relative)

In the next part, I use MediaEnded to load the next

    Private Sub Media_Org_MediaEnded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Media_Org.MediaEnded

            i = i + 1
            If i = listbox1.Items.Count Then
                i = 0
            End If
            Media_Org.Source = New Uri(listbox1.Items(i), UriKind.Relative)
End Sub

Any suggestions?

"Another problem is that the processor plays up to 60-70% when playing videos

+3
source share
1 answer

, , . , MediaElement , , . Microsoft , MediaElement. WPF MediaKit, http://wpfmediakit.codeplex.com/, . , .

+1

Source: https://habr.com/ru/post/1796510/


All Articles