HowTo play a sound in Avalon?

Windows Presentation Foundation (formerly Avalon) Beta 1 is fully equipped with Video and Audio playback features. Great! But I had to play a while until I was able to play a simple Microsoft WMA file ...
The releasenotes say there is a new Class named MediaElement. It didn’t work for me without adding it to a Avalon Page/Window so I forgot about creating all items by code an added the element to the window's XAML what worked fine. Maybe it has to be bound to a page?

Xaml:


VB:
medPlayer.Source = New MediaTimeline(New System.Uri(path))
medPlayer.Source.CreateClock.Begin


The file played and I was pleased. Then I wanted to implement some status display and recognized the MediaClock’s CurrentProgress Property. But somehow it didn’t change. I had to set the MediaTimeline’s Duration Property to MediaTimeline’s MediaDuration value first what worked great for some files but didn't for others. I'm a bit confuesd because sometimes the playback dies without reason and I have to restart my app again. Maybe I will better wait for Beta 2 ;-)

Comments

Popular posts from this blog

Custom Chrome in WPF

Capture WebCam with WinForms2

WPF: Binding updates