/// <summary>
        /// Registers element for current media stream source
        /// </summary>
        /// <param name="element"></param>
        private void RegisterWith(MediaElement element)
        {
            if (_extensionManager != null)
            {
                throw new InvalidOperationException("MediaStreamSource is already registered with a media element.");
            }

            _extensionManager = new MediaExtensionManager();
            var config = new Windows.Foundation.Collections.PropertySet();

            // Registration of the scheme handler is global, so we need to get unique scheme so our
            // plugin will be used only for our this one instance of media element.
            string uri = "samplemss-" + element.GetHashCode() + ":";

            config.Add("plugin", new MMSWinRTPlugin(this));
            _extensionManager.RegisterSchemeHandler("MSSWinRTExtension.MediaStreamSchemeHandler", uri, config);

            element.Source = new Uri(uri);
        }