/// <summary> /// Handles the <see cref="E:ElementPropertyChanged" /> event. /// </summary> /// <param name="sender">The sender.</param> /// <param name="e">The <see cref="System.ComponentModel.PropertyChangedEventArgs"/> instance containing the event data.</param> protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { // Xamarin will changed the renderer attached to a view so it is possible that // an old renderer gets a property updated. In this case the Element will be null. // In that case, try to clear the property event handler and exit. if (Element == null) { HybridWebViewV2 wv = sender as HybridWebViewV2; if (wv != null) { wv.PropertyChanged -= this.OnElementPropertyChanged; } return; } base.OnElementPropertyChanged(sender, e); if (e.PropertyName == HybridWebViewV2.UriProperty.PropertyName) { this.Load(this.Element.Uri); } else if (e.PropertyName == HybridWebViewV2.SourceProperty.PropertyName) { LoadSource(); } else if (e.PropertyName == HybridWebViewV2.CleanupProperty.PropertyName) { HandleCleanup(); } }
/// <summary> /// Due to issues with the XLabs library, the HybridWebView control will only load if called programatically in code. /// </summary> private void createMediaViewerVideo() { MediaViewerVideo = new HybridWebViewV2() { VerticalOptions = LayoutOptions.FillAndExpand, HorizontalOptions = LayoutOptions.FillAndExpand }; MediaViewerVideo.Source = Constants.StreamrAPIUrl + "youtubeview"; MediaViewerVideo.SetBinding(HybridWebViewV2.HeightRequestProperty, "MediaHeight"); MediaViewerVideo.SetBinding(HybridWebViewV2.IsVisibleProperty, "IsLoaded"); MediaViewerVideo.BindingContext = thisViewModel; MediaViewerVideo.InputTransparent = true; MediaViewer.Children.Add(MediaViewerVideo); MediaViewer.LowerChild(MediaViewerVideo); MediaViewerVideo.LoadFinished += new EventHandler(MediaViewerLoaded); MediaViewerVideo.RegisterCallback("videoPlaying", (arg) => { mewmont.Models.Javascript.PlaybackState playbackState = serializer.Deserialize <mewmont.Models.Javascript.PlaybackState>(arg); if (playbackState.playbackState != 1) { MediaViewerPlaceholder.IsVisible = true; } else { MediaViewerPlaceholder.IsVisible = false; } }); }
private void Unbind(HybridWebViewV2 oldElement) { if (oldElement != null) { oldElement.JavaScriptLoadRequested -= OnInjectRequest; oldElement.LoadFromContentRequested -= LoadFromContent; oldElement.LoadContentRequested -= LoadContent; oldElement.PropertyChanged -= this.OnElementPropertyChanged; } }