24/7 computer, problem with mediaelement WPF, turns black after 3h
I have a computer that are going to run a WPF program 24/7 and play a playlist of images and videos. When I start my program everything works perfectly, but after maybe 2-3h the mediaelement windows is black.
When I start the program, it takes all the filenames in a folder and puts it in a listbox
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)
The next part is that I use MediaEnded to load the开发者_开发问答 next one
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 I have is that the cpu goes up to 60-70% when I play videos"
I was working on a project that would play videos in a folder and videos were being added to that folder at some time interval. There were occasions where the MediaElement would look like it was not playing the file but the position of the video would continue. We had talked with Microsoft and concluded that it was a bug in the the MediaElement control. We ended up using the WPF MediaKit, http://wpfmediakit.codeplex.com/, which solved most of the problems. I hope this helps.
精彩评论