“MediaElement.SetSource” throws “AE_INVALID_FORMAT_ERROR” when setting “Stream” sources

When reading a stream from a location such as a media resource object, and then calling “MediaElement.SetSource” may return “AE_INVALID_FORMAT_ERROR”. If you construct a “MemoryStream” using your “Stream” object (reading all bytes and writing to a MemoryStream), then “SetSource” works fine.

This issue may ocur when the “Stream” object is not seekable. A “MemoryStream” will always be seekable and will always work with “SetSource”. "SetSource" always expects a seekable “Stream”.