// To avoid blocking the UI thread, SoundPlayerAction performs an asynchronous // download of the WebResponse and later, the response Stream. However, // PackWebRequest does not support the asynchonous Begin/EndGetResponse pattern. // To work around this, we use our own asynchronous worker pool thread, // and then use the regular synchronous WebRequest.GetResponse() method. // Once we obtain the WebResponse, we will use SoundPlayer's async API // to download the content of the stream. private void OnSourceChangedHelper(Uri newValue) { if (newValue == null || newValue.IsAbsoluteUri) { m_lastRequestedAbsoluteUri = newValue; } else { // When we are given a relative Uri path, expand to an absolute Uri by resolving // it against the Application's base Uri. This would typically return a Pack Uri. m_lastRequestedAbsoluteUri = BaseUriHelper.GetResolvedUri(BaseUriHelper.BaseUri, newValue); } // Invalidate items that depend on the Source uri m_player = null; m_playRequested = false; // Suppress earlier requests to Play the sound if (m_streamLoadInProgress) { // There is already a worker thread downloading the previous URI stream, // or the SoundPlayer is copying the stream into its buffer. Make a note // that the URI has been changed and we will have to reload everything. m_uriChangedWhileLoadingStream = true; } else { BeginLoadStream(); } }
/// <summary> /// This method is invoked whenever the source property changes. /// </summary> private void UriSourcePropertyChangedHook(DependencyPropertyChangedEventArgs e) { // Decided against comparing the URI because the user might want to change the shader on the filesystem // and reload it. // We do not support async loading of shaders here. If that is desired the user needs to use the SetStreamSource // API. Uri newUri = (Uri)e.NewValue; Stream stream = null; try { if (newUri != null) { if (!newUri.IsAbsoluteUri) { newUri = BaseUriHelper.GetResolvedUri(BaseUriHelper.BaseUri, newUri); } Debug.Assert(newUri.IsAbsoluteUri); // Now the URI is an absolute URI. // // Only allow file and pack URIs. if (!newUri.IsFile && !PackUriHelper.IsPackUri(newUri)) { throw new ArgumentException(SR.Get(SRID.Effect_SourceUriMustBeFileOrPack)); } stream = WpfWebRequestHelper.CreateRequestAndGetResponseStream(newUri); } LoadPixelShaderFromStreamIntoMemory(stream); } finally { if (stream != null) { stream.Dispose(); } } }
// Token: 0x06005650 RID: 22096 RVA: 0x0017E5E8 File Offset: 0x0017C7E8 private void OnSourceChangedHelper(Uri newValue) { if (newValue == null || newValue.IsAbsoluteUri) { this.m_lastRequestedAbsoluteUri = newValue; } else { this.m_lastRequestedAbsoluteUri = BaseUriHelper.GetResolvedUri(BaseUriHelper.BaseUri, newValue); } this.m_player = null; this.m_playRequested = false; if (this.m_streamLoadInProgress) { this.m_uriChangedWhileLoadingStream = true; return; } this.BeginLoadStream(); }
internal static CodeAccessPermission CreateMediaAccessPermission(string uri) { CodeAccessPermission result = null; if (uri != null) { if (string.Compare("image", uri, true, TypeConverterHelper.InvariantEnglishUS) == 0) { result = new MediaPermission(MediaPermissionAudio.NoAudio, MediaPermissionVideo.NoVideo, MediaPermissionImage.AllImage); } else if (string.Compare(BaseUriHelper.GetResolvedUri(BaseUriHelper.BaseUri, new Uri(uri, UriKind.RelativeOrAbsolute)).Scheme, PackUriHelper.UriSchemePack, true, TypeConverterHelper.InvariantEnglishUS) != 0 && !CallerHasWebPermission(new Uri(uri, UriKind.RelativeOrAbsolute))) { result = new MediaPermission(MediaPermissionAudio.NoAudio, MediaPermissionVideo.NoVideo, MediaPermissionImage.AllImage); } } else { result = new MediaPermission(MediaPermissionAudio.NoAudio, MediaPermissionVideo.NoVideo, MediaPermissionImage.AllImage); } return(result); }