Events not firing from media opened when SMFPlayer is collapsed

Feb 9, 2011 at 11:16 AM

Hi all,


It seems from our testing that if the SMFPlayer instance is set to Visibility=Collapsed then events that we would expect to fire fail to do so. The one in particular is the MediaOpened event. The code for this event inside the SMFPlayer is below. This event fires if the player is marked as visible and fails to do so if collapsed. Is this expected behaviour? (We want the player collapsed whilst we are retrieving data from a service. The data includes the media to play. There are obviously other times when we wish to hide the player (for instance if a custom ad is playing, so are concerned this will cause event firing issues.:




private void MediaPlugin_MediaOpened(IMediaPlugin mediaPlugin)


 //All MediaPlugin events are being dispatched to the UI thread because



 //they may likely be coming in from another thread and errors can occur 


//if they interact with the UI





Feb 9, 2011 at 6:34 PM

Neilthespod, interesting observation. I took a look at what was happening and the behavior is due to the the fact that OnApplyTemplate doesn't get called until the control is visible and in the visual tree. This is a general Silverlight behavior for all controls, not just SMF. In SMF, much of the initialization cannot take place until that method is called so no playback/media opening will occur until after OnApplyTemplate is called.

One possible workaround would be to set opactity = 0 instead.

Tim Greenfield

Feb 9, 2011 at 8:01 PM

Thanks Tim,

Once the item is first rendered in the tree (and therefore has templates applied) does setting visibility to Collapsed then prevent events firing ? So are we just seeing a first time instantiation problem or will it cause controls to "go silent" once collapsed ?





(Yes I really must change my name in my Live profile)