private async void frame_Loaded(object sender, RoutedEventArgs e) { init = true; if (!DownloadManager.IsFullScreenAsset(_url)) { this.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; this.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top; this.Margin = new Thickness(_rect.Left * _offset, (_rect.Top + 1.5) * _offset, 0, 0); this.Width = _rect.Width * _offset; this.Height = _rect.Height * _offset; } else { this.Width = _rect.Width; this.Height = _rect.Height; this.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; this.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center; btnFullScreen.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } videoPlayer.Width = this.Width; videoPlayer.Height = this.Height; webView.Width = this.Width; webView.Height = this.Height; if (DownloadManager.IsLocalAsset(_url)) { StorageFolder folder = null; try { folder = await StorageFolder.GetFolderFromPathAsync(_folderUrl); } catch { error = true; noAsset.Visibility = Windows.UI.Xaml.Visibility.Visible; if (DownloadManager.IsFullScreenAsset(_url) || DownloadManager.IsAutoPlay(_url)) { Start(); } return; } var pos = _url.IndexOf(".mp4"); StorageFile file = null; try { var str = folder.Path + "\\" + _url.Substring(0, pos).Replace("http://localhost/", "") + ".mp4"; file = await StorageFile.GetFileFromPathAsync(str); var stream = await file.OpenAsync(Windows.Storage.FileAccessMode.Read); var unprotected = await DownloadManager.UnprotectPDFStream(stream); var tmp = await ApplicationData.Current.LocalFolder.CreateFileAsync("tmp.mp4", CreationCollisionOption.ReplaceExisting); using (var tmpStream = await tmp.OpenAsync(FileAccessMode.ReadWrite)) { await RandomAccessStream.CopyAndCloseAsync(unprotected.GetInputStreamAt(0), tmpStream.GetOutputStreamAt(0)); await tmpStream.FlushAsync(); } tmp = null; tmp = await ApplicationData.Current.LocalFolder.GetFileAsync("tmp.mp4"); stream = await tmp.OpenAsync(FileAccessMode.Read); videoPlayer.SetSource(stream, file.ContentType); if (DownloadManager.IsFullScreenAsset(_url) || DownloadManager.IsAutoPlay(_url)) { Start(); } } catch (Exception) { error = true; noAsset.Visibility = Windows.UI.Xaml.Visibility.Visible; if (DownloadManager.IsFullScreenAsset(_url) || DownloadManager.IsAutoPlay(_url)) { Start(); } return; } } else { Start(); videoPlayer.Visibility = Windows.UI.Xaml.Visibility.Collapsed; webView.Visibility = Windows.UI.Xaml.Visibility.Visible; webView.Navigate(new Uri(_url)); HideUI(); } }
public async Task SetRect(Rect rect, string folderUrl, string url, float offset) { var loader = new ResourceLoader(); textInfo.Text = loader.GetString("slide_show_inf"); if (!DownloadManager.IsFullScreenAsset(url)) { this.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Left; this.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Top; this.Margin = new Thickness(rect.Left * offset, (rect.Top + 1.5) * offset, 0, 0); this.Width = rect.Width * offset; this.Height = rect.Height * offset; } else { info.Visibility = Windows.UI.Xaml.Visibility.Visible; this.Width = Window.Current.Bounds.Width; this.Height = Window.Current.Bounds.Height; this.HorizontalAlignment = Windows.UI.Xaml.HorizontalAlignment.Center; this.VerticalAlignment = Windows.UI.Xaml.VerticalAlignment.Center; enabled = true; fullScreen = true; } string startMame = null; string endName = null; //if (!DownloadManager.IsFullScreenAsset(url)) //{ // images.Add(new ImageData() { Image = null, Width = this.Width, Height = this.Height }); //} StorageFolder folder = null; try { folder = await StorageFolder.GetFolderFromPathAsync(folderUrl); int start = 0; int end = 0; if (url.Contains(".jpg")) { start = url.IndexOf('_'); end = url.IndexOf(".jpg"); startMame = url.Substring(0, start + 1); startMame = startMame.Replace("http://localhost/", ""); endName = ".jpg"; } else if (url.Contains(".png")) { start = url.IndexOf('_'); end = url.IndexOf(".png"); startMame = url.Substring(0, start + 1); endName = ".png"; } if (start == -1 || end == -1) { throw new Exception(); } var test = url.Substring(start + 1, end - start); length = Convert.ToInt32(url.Substring(start + 1, end - start - 1)); } catch { //if (!DownloadManager.IsFullScreenAsset(url)) //{ // images.Add(new ImageData() { Image = null, Width = this.Width, Height = this.Height }); //} for (int p = 0; p < 1; p++) { images.Add(new ImageData() { Image = null, NotDownloaded = true, Width = this.Width, Height = this.Height }); } //progressLoad.IsActive = false; return; } var maxWidth = this.Width; var maxHeight = this.Height; for (int i = 1; i <= length; i++) { StorageFile file = null; try { var str = folder.Path + "\\" + startMame + i + endName; file = await StorageFile.GetFileFromPathAsync(folder.Path + "\\" + startMame + i + endName); using (var stream = await file.OpenAsync(FileAccessMode.Read)) { var unprotected = await DownloadManager.UnprotectPDFStream(stream); var bitmap = new BitmapImage(); await bitmap.SetSourceAsync(unprotected); if (DownloadManager.IsFullScreenAsset(url)) { maxWidth = maxWidth < bitmap.PixelWidth ? bitmap.PixelWidth : maxWidth; maxHeight = maxHeight < bitmap.PixelHeight ? bitmap.PixelHeight : maxHeight; images.Add(new ImageData() { Image = bitmap, ImgStretch = Stretch.Uniform, Hidden = true, Width = this.Width, Height = this.Height }); } else { images.Add(new ImageData() { Image = bitmap, ImgStretch = Stretch.Uniform, Hidden = true, Width = this.Width, Height = this.Height }); } } } catch { images.Add(new ImageData() { Image = null, NotDownloaded = true, Width = this.Width, Height = this.Height }); //progressLoad.IsActive = false; } } //if (!DownloadManager.IsFullScreenAsset(url)) //{ // images.Add(new ImageData() { Image = null, Width = this.Width, Height = this.Height }); //} //else //{ //if (maxHeight > Window.Current.Bounds.Height) //{ // maxWidth = maxWidth * (Window.Current.Bounds.Height) / maxHeight; // maxHeight = Window.Current.Bounds.Height; //} //this.Width = maxWidth; //this.Height = maxHeight; //foreach (var image in images) //{ // image.Width = maxWidth; // image.Height = maxHeight; //} //} itemListView.ItemsSource = images; if (DownloadManager.IsAutoPlay(url)) { autoSlide = true; enabled = true; } if (DownloadManager.IsNoTransitions(url)) { noTranstions = true; enabled = true; } if (url.Contains("wadelay=")) { var pp = url.IndexOf("wadelay="); interval = Convert.ToInt32(url.Substring(pp + 8, 3)); } //progressLoad.IsActive = false; }