views:

24

answers:

1

i have written a custom mediastreamsource, that can play media from growing source files (mpeg transport streams). Once it reaches the end of its mediastream, it reads the new duration from the mediafile and continues to deliver samples. The MediaElement plays continously.

Unfortunately i haven´t found a way to update the MediaElement.NaturalDuration property. Hence i cannot seek into the “reloaded” area, because ME doesn´t know about it and sets my position change to its NaturalDuration value.

I tried to call ReportOpenMediaCompleted after getting the new stream length. Then Naturalduration get´s updated, but i cannot play anymore.

Is there any other way to deal with it ?

A: 

Sometime life can be so easy :-)

I solved it giving MediaElement a "fantasy" duration value when initializing my MediaStreamSource :

protected override void OpenMediaAsync()
{
...
mediaSourceAttributes[MediaSourceAttributesKeys.Duration] = TimeSpan.FromHours(10).Ticks.ToString(CultureInfo.InvariantCulture);
this.ReportOpenMediaCompleted(mediaSourceAttributes, mediaStreamDescriptions);
}

The only thing left to do was to update my slider control with the "real" duration. Now it works like a charm ...

Tilo

Tilo Skomudek