Initial StartupPosition not respected with HTTP URLs

Topics: Windows Phone 8
Jan 31, 2014 at 7:10 PM
This reproduces with the latest stable and beta Player Frameworks. It also reproduces only on Windows Phone 8. Windows 8/8.1 works fine.

The symptom is this: if you create a playlist item with an HTTP url as the Source and set a timespan as the StartupPosition, the video plays from the beginning instead of from the StartupPosition.

The reason, as far as I can tell, is that the MediaPlayer's CanSeek property is set to false until fairly late in the playback game. Even in MediaOpened and MediaStarted events, it remains false. It becomes true somewhere down the road, but there isn't an event that tells us at the perfect time (at least that I'm aware of).

The workaround is to check for CanSeek being true with periodic events like CurrentStateChanged and PositionChanged, then perform an initial Seek. It's a bit clumsy, causes two buffering events when resuming video, and sometimes shows initial frames from the video before resuming. So not ideal.

Any chance we could get this fixed so that StartupPosition is respected? I do realize that the issue may be in the underlying infrastructure.


(Oh, and Netmon captures indicate the servers I've tested are all returning Accept-Ranges: bytes for each request, so that's not the problem.)
Feb 2, 2014 at 5:29 PM
Thanks for reporting this. I was able to track down the issue to what appears to be a MediaElement bug on WP (or at least a strange behavior). It turns out you cannot set MediaElement.Position before calling MediaElement.Play when MediaElement.AutoPlay = false.

I've checked in a fix for the issue to CodePlex repo.

Note: you can also workaround the issue with the current build by either:
1) set AllowMediaStartingDeferrals=false. However, you should not do this if you have pre-roll ads or they will not play.
2) Set MediaPlayer.StartupPosition AND seek on your own the first time CurrentStatusChanged fires after MediaOpened.
Feb 5, 2014 at 1:42 AM
AllowMediaStartingDeferrals looks to be a solid workaround.

Thanks for the investigation!
Apr 7, 2014 at 10:01 AM
Hi, I'm experiencing this problem as well, the trick with AllowMediaStartingDeferrals works for now.
Any idea when stable version for WP8 with this fix will be released?
May 5, 2014 at 6:20 PM
The next public stable release should be ready in 2 weeks (May 19). This new version will be based on the latest v2 beta -- available to download today for early feedback.

Regards, Tim