public override void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) return; string filename = EditorUtility.OpenFilePanel("Load file", "", generateFilterValue(fileTypes)); if (!string.IsNullOrEmpty(filename)) { if (maxWidth == 0 || maxHeight == 0 || folderLocation != FolderLocations.Pictures) { streamLoadedCallback(new FileStream(filename, FileMode.Open, FileAccess.Read), true); } else { var newStream = new MemoryStream(); try { using (var stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { IImageDecoder decoder = null; switch (Path.GetExtension(filename).ToLower()) { case ".jpg": decoder = new JpegDecoder(); break; case ".jpeg": decoder = new JpegDecoder(); break; case ".png": decoder = new PngDecoder(); break; default: Debug.LogError("Unsuported file ext type: " + Path.GetExtension(filename)); streamLoadedCallback(null, false); return; } var image = new ExtendedImage(); decoder.Decode(image, stream); var newSize = MathUtilities.FitInViewIfLarger(image.PixelWidth, image.PixelHeight, maxWidth, maxHeight); var newImage = ExtendedImage.Resize(image, (int)newSize.x, (int)newSize.y, new NearestNeighborResizer()); var encoder = new PngEncoder(); encoder.Encode(newImage, newStream); newStream.Position = 0; } } catch (Exception e) { newStream.Dispose(); newStream = null; Debug.LogError(e.Message); } finally { streamLoadedCallback(newStream, true); } } } else { streamLoadedCallback(null, false); } }
public override void Update() { if (native.CallStatic <bool>("CheckSaveImageDone")) { if (streamFileSavedCallback != null) { streamFileSavedCallback(native.CallStatic <bool>("CheckSaveImageSucceeded")); streamFileSavedCallback = null; } } if (native.CallStatic <bool>("CheckLoadImageDone")) { if (streamFileLoadedCallback != null) { bool succeeded = native.CallStatic <bool>("CheckLoadImageSucceeded"); if (succeeded) { streamFileLoadedCallback(new MemoryStream(native.CallStatic <byte[]>("GetLoadedImageData")), succeeded); } else { streamFileLoadedCallback(null, succeeded); } streamFileLoadedCallback = null; } } }
public void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback != null) { streamLoadedCallback(null, false); } }
public override void Update() { if (CheckImageSavedDoneStatus()) { if (streamFileSavedCallback != null) { streamFileSavedCallback(CheckImageSavedSucceededStatus()); streamFileSavedCallback = null; } } if (CheckImageLoadStatus()) { if (streamFileLoadedCallback != null) { bool succeeded; byte[] data = null; unsafe { IntPtr dataPtr = IntPtr.Zero; int dataSize; succeeded = CheckImageLoadSucceededStatus(ref dataPtr, &dataSize); if (succeeded) { data = new byte[dataSize]; Marshal.Copy(dataPtr, data, 0, data.Length); Marshal.FreeHGlobal(dataPtr); } } streamFileLoadedCallback(succeeded ? new MemoryStream(data) : null, succeeded); streamFileLoadedCallback = null; } } }
public void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) { return; } loadFileAsync(fileName, folderLocation, streamLoadedCallback); }
public override void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (folderLocation != FolderLocations.Storage) { Debug.LogError("Load file in folder location: " + folderLocation + " is not supported."); streamLoadedCallback(null, false); } else { base.LoadFile(fileName, folderLocation, streamLoadedCallback); } }
void photoChooserTask_Completed(object sender, PhotoResult e) { var callback = photoChooserTask_StreamLoadedCallback; var fileTypes = photoChooserTask_fileTypes; int maxWidth = photoChooserTask_maxWidth, maxHeight = photoChooserTask_maxHeight; photoChooserTask_StreamLoadedCallback = null; photoChooserTask_fileTypes = null; photoChooser = null; if (e.TaskResult != TaskResult.OK) { if (callback != null) { callback(null, false); } return; } string fileExt = getFileExt(e.OriginalFileName).ToLower(); foreach (var type in fileTypes) { if (getFileExt(type).ToLower() == fileExt) { if (callback != null && e.TaskResult == TaskResult.OK) { var stream = e.ChosenPhoto; if (maxWidth == 0 || maxHeight == 0) { callback(stream, true); } else { var scaledStream = resizeImageStream(stream, maxWidth, maxHeight); callback(scaledStream, true); } } else if (callback != null) { callback(null, false); } return; } } if (callback != null) { callback(null, false); } }
public override void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (folderLocation != FolderLocations.Pictures) { Debug.LogError("LoadFileDialog not supported for folder location: " + folderLocation + " on this Platform yet."); streamLoadedCallback(null, false); } else { streamFileLoadedCallback = streamLoadedCallback; LoadImagePicker(maxWidth, maxHeight, x, y, width, height); } }
/// <summary> /// Use to have to user pic a file on iOS. (Remember to dispose loaded stream) /// NOTE: The x, y, width, height is ONLY for iOS (other platforms ignore these values). /// </summary> /// <param name="folderLocation">Folder location from where the user should choose from.</param> /// <param name="maxWidth">Image size returned will not be above the Max Width value (set 0 to disable)</param> /// <param name="maxHeight">Image size returned will not be above the Max Height value (set 0 to disable)</param> /// <param name="x">iOS iPad dlg X.</param> /// <param name="y">iOS iPad dlg Y.</param> /// <param name="width">iOS iPad dlg Width.</param> /// <param name="height">iOS iPad dlg Height.</param> /// <param name="fileTypes">File types the user can see in file popup.</param> /// <param name="streamLoadedCallback">The callback that fires when done.</param> public static void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (loadingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.LoadFileDialog); que.streamLoadedCallback = streamLoadedCallback; que.FolderLocation = folderLocation; que.FileTypes = fileTypes; ques.Add(que); return; } loadingStream = true; StreamManager.streamLoadedCallback = streamLoadedCallback; plugin.LoadFileDialog(folderLocation, maxWidth, maxHeight, x, y, width, height, fileTypes, async_streamLoadedCallback); }
/// <summary> /// Use to load a file. /// </summary> /// <param name="fileName">FileName to load.</param> /// <param name="folderLocation">Folder location to load from.</param> /// <param name="streamLoadedCallback">The callback that fires when done.</param> public static void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (loadingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.LoadFile); que.streamLoadedCallback = streamLoadedCallback; que.FileName = fileName; que.FolderLocation = folderLocation; ques.Add(que); return; } loadingStream = true; StreamManager.streamLoadedCallback = streamLoadedCallback; plugin.LoadFile(getCorrectUnityPath(fileName, folderLocation), folderLocation, async_streamLoadedCallback); }
/// <summary> /// Use to have the user take a picture with there native camera /// </summary> /// <param name="quality">Camera resolution quality (Has no effect on some defices)</param> /// <param name="maxWidth">Image size returned will not be above the Max Width value (set 0 to disable)</param> /// <param name="maxHeight">Image size returned will not be above the Max Height value (set 0 to disable)</param> /// <param name="streamLoadedCallback">Callback fired when done</param> public static void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { if (loadingStream) { var que = new StreamManagerQue(StreamManagerQueTypes.LoadCameraPicker); que.streamLoadedCallback = streamLoadedCallback; que.MaxWidth = maxWidth; que.MaxHeight = maxHeight; que.CameraQuality = quality; ques.Add(que); return; } loadingStream = true; StreamManager.streamLoadedCallback = streamLoadedCallback; plugin.LoadCameraPicker(quality, maxWidth, maxHeight, async_streamLoadedCallback); }
public override void Update() { if (native.CallStatic<bool>("CheckSaveImageDone")) { if (streamFileSavedCallback != null) { streamFileSavedCallback(native.CallStatic<bool>("CheckSaveImageSucceeded")); streamFileSavedCallback = null; } } if (native.CallStatic<bool>("CheckLoadImageDone")) { if (streamFileLoadedCallback != null) { bool succeeded = native.CallStatic<bool>("CheckLoadImageSucceeded"); if (succeeded) streamFileLoadedCallback(new MemoryStream(native.CallStatic<byte[]>("GetLoadedImageData")), succeeded); else streamFileLoadedCallback(null, succeeded); streamFileLoadedCallback = null; } } }
public virtual void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) return; MemoryStream stream = null; try { using (var file = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { var data = new byte[file.Length]; file.Read(data, 0, data.Length); stream = new MemoryStream(data); } } catch (Exception e) { if (stream != null) stream.Dispose(); Debug.LogError(e.Message); streamLoadedCallback(null, false); return; } streamLoadedCallback(stream, true); }
private async void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) #endif { #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(delegate() { loadCameraPicker_streamLoadedCallback = streamLoadedCallback; loadCameraPicker_maxWidth = maxWidth; loadCameraPicker_maxHeight = maxHeight; var cameraCaptureTask = new CameraCaptureTask(); cameraCaptureTask.Completed += new EventHandler<PhotoResult>(cameraCaptureTask_Completed); cameraCaptureTask.Show(); }); #elif UNITY_WP_8_1 loadFileDialogAsync(FolderLocations.Pictures, maxWidth, maxHeight, new string[]{".jpg"}, streamLoadedCallback); #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() { try { var cameraUI = new CameraCaptureUI(); cameraUI.PhotoSettings.AllowCropping = false; switch (quality) { case CameraQuality.Low: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.SmallVga; break; case CameraQuality.Med: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.MediumXga; break; case CameraQuality.High: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; break; } var capturedMedia = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Photo); if (capturedMedia != null) { using (var cameraStream = await capturedMedia.OpenAsync(FileAccessMode.Read)) { if (maxWidth == 0 || maxHeight == 0) { ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(cameraStream.AsStream(), true); }); } else { var stream = await resizeImageStream(cameraStream, maxWidth, maxHeight); ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(stream, true); }); } } } else { ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(null, false); }); } } catch (Exception e) { Debug.LogError(e.Message); ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(null, false); }); } }); #endif }
public void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { Native.LoadFileDialog(folderLocation, maxWidth, maxHeight, x, y, width, height, fileTypes, streamLoadedCallback); }
private void loadFileDialogAsync(FolderLocations folderLocation, int maxWidth, int maxHeight, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback)
public void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) streamLoadedCallback(null, false); else loadCameraPickerAsync(quality, maxWidth, maxHeight, streamLoadedCallback); }
/// <summary> /// Use to have to user pic a file on iOS. (Remember to dispose loaded stream) /// NOTE: The x, y, width, height is ONLY for iOS (other platforms ignore these values). /// </summary> /// <param name="folderLocation">Folder location from where the user should choose from.</param> /// <param name="x">iOS iPad dlg X.</param> /// <param name="y">iOS iPad dlg Y.</param> /// <param name="width">iOS iPad dlg Width.</param> /// <param name="height">iOS iPad dlg Height.</param> /// <param name="fileTypes">File types the user can see in file popup.</param> /// <param name="streamLoadedCallback">The callback that fires when done.</param> public static void LoadFileDialog(FolderLocations folderLocation, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { LoadFileDialog(folderLocation, 0, 0, 0, 0, 10, 10, fileTypes, streamLoadedCallback); }
public virtual void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { Debug.LogError("LoadCameraPicker not supported on this Platform!"); if (streamLoadedCallback != null) { streamLoadedCallback(null, false); } }
/// <summary> /// Use to have the user take a picture with there native camera /// </summary> /// <param name="quality">Camera resolution quality (Has no effect on some defices)</param> /// <param name="streamLoadedCallback">Callback fired when done</param> public static void LoadCameraPicker(CameraQuality quality, StreamLoadedCallbackMethod streamLoadedCallback) { LoadCameraPicker(quality, 0, 0, streamLoadedCallback); }
public void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback != null) streamLoadedCallback(null, false); }
public virtual void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) { return; } MemoryStream stream = null; try { using (var file = new FileStream(fileName, FileMode.Open, FileAccess.Read)) { var data = new byte[file.Length]; file.Read(data, 0, data.Length); stream = new MemoryStream(data); } } catch (Exception e) { if (stream != null) { stream.Dispose(); } Debug.LogError(e.Message); streamLoadedCallback(null, false); return; } streamLoadedCallback(stream, true); }
public void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) { return; } loadFileDialogAsync(folderLocation, maxWidth, maxHeight, fileTypes, streamLoadedCallback); }
public override void LoadCameraPicker (CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { if (Common.navigator_invoke_invocation_create(ref invoke) != 0) return; if (Common.navigator_invoke_invocation_set_target(invoke, "sys.camera.card") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_action(invoke, "bb.action.CAPTURE") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_type(invoke, "image/jpeg") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } string name = "photo"; IntPtr namePtr = Marshal.StringToHGlobalAnsi(name); if (Common.navigator_invoke_invocation_set_data(invoke, namePtr, name.Length) != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_send(invoke) != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } var fileTypes = new string[] { ".jpg", "jpeg", ".png" }; var dataPathPatterns = new string[] { @"(/accounts/1000/shared/camera/)([\w|\.|\-]*)", @"(/accounts/1000/shared/photos/)([\w|\.|\-]*)" }; waitAndProcessImage(addUppers(fileTypes), dataPathPatterns, maxWidth, maxHeight, streamLoadedCallback); Common.navigator_invoke_invocation_destroy(invoke); Marshal.FreeHGlobal(namePtr); }
public override void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (folderLocation != FolderLocations.Pictures) { Debug.LogError("LoadFileDialog not supported for folder location: " + folderLocation + " on this Platform yet."); streamLoadedCallback(null, false); } else { if (Common.navigator_invoke_invocation_create(ref invoke) != 0) return; if (Common.navigator_invoke_invocation_set_target(invoke, "sys.filepicker.target") != 0)// sys.filesaver.target << use for file save dialog { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_action(invoke, "bb.action.OPEN") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_type(invoke, "application/vnd.blackberry.file_picker") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_send(invoke) != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } var dataPathPatterns = new string[] { @"file\://(/accounts/1000/shared/photos/)([\w|\.|\-]*)", @"file\://(/accounts/1000/shared/camera/)([\w|\.|\-]*)", @"file\://(/accounts/1000/shared/downloads/)([\w|\.|\-]*)" }; waitAndProcessImage(addUppers(fileTypes), dataPathPatterns, maxWidth, maxHeight, streamLoadedCallback); Common.navigator_invoke_invocation_destroy(invoke); } }
public void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback != null) streamLoadedCallback(null, false); }
public override void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) { return; } // open native dlg var file = new OPENFILENAME(); file.lStructSize = (uint)Marshal.SizeOf(typeof(OPENFILENAME)); file.hwndOwner = IntPtr.Zero; file.lpstrDefExt = IntPtr.Zero; file.lpstrFile = Marshal.AllocHGlobal((int)MAX_PATH); unsafe { ((byte *)file.lpstrFile.ToPointer())[0] = 0; } file.nMaxFile = MAX_PATH; file.lpstrFilter = generateFilterValue(fileTypes); file.nFilterIndex = 0; file.lpstrInitialDir = Marshal.StringToHGlobalUni(Application.dataPath); file.lpstrTitle = Marshal.StringToHGlobalUni("Load file"); file.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR; GetOpenFileName(ref file); // get native dlg result string filename = null; if (file.lpstrFile != IntPtr.Zero) { filename = Marshal.PtrToStringUni(file.lpstrFile); Debug.Log("Loading file: " + filename); } Marshal.FreeHGlobal(file.lpstrFile); Marshal.FreeHGlobal(file.lpstrInitialDir); Marshal.FreeHGlobal(file.lpstrTitle); Marshal.FreeHGlobal(file.lpstrFilter); // open file if (!string.IsNullOrEmpty(filename)) { if (maxWidth == 0 || maxHeight == 0 || folderLocation != FolderLocations.Pictures) { streamLoadedCallback(new FileStream(filename, FileMode.Open, FileAccess.Read), true); } else { var newStream = new MemoryStream(); try { using (var stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { ImageTools.IO.IImageDecoder decoder = null; switch (Path.GetExtension(filename).ToLower()) { case ".jpg": decoder = new ImageTools.IO.Jpeg.JpegDecoder(); break; case ".jpeg": decoder = new ImageTools.IO.Jpeg.JpegDecoder(); break; case ".png": decoder = new ImageTools.IO.Png.PngDecoder(); break; default: Debug.LogError("Unsuported file ext type: " + Path.GetExtension(filename)); streamLoadedCallback(null, false); return; } var image = new ExtendedImage(); decoder.Decode(image, stream); var newSize = Reign.MathUtilities.FitInViewIfLarger(image.PixelWidth, image.PixelHeight, maxWidth, maxHeight); var newImage = ExtendedImage.Resize(image, (int)newSize.x, (int)newSize.y, new NearestNeighborResizer()); var encoder = new PngEncoder(); encoder.Encode(newImage, newStream); newStream.Position = 0; } } catch (Exception e) { newStream.Dispose(); newStream = null; Debug.LogError(e.Message); } finally { streamLoadedCallback(newStream, true); } } } else { streamLoadedCallback(null, false); } }
private async void loadFileAsync(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { Stream stream = null; try { #if WINDOWS_PHONE if (folderLocation == FolderLocations.Pictures) { using (var m = new MediaLibrary()) { foreach (var p in m.Pictures) { if (p.Name == fileName) { streamLoadedCallback(p.GetImage(), true); p.Dispose(); return; } else { p.Dispose(); } } } streamLoadedCallback(null, false); return; } #endif fileName = fileName.Replace('/', '\\'); stream = await openStream(fileName, folderLocation); } catch (Exception e) { if (stream != null) { stream.Dispose(); } Debug.LogError(e.Message); streamLoadedCallback(null, false); return; } streamLoadedCallback(stream, stream != null); }
private void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback)
private static void waitAndProcessImage(string[] fileTypes, string[] dataPathPatterns, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { // wait for event while (true) { IntPtr _event = IntPtr.Zero; Common.bps_get_event(ref _event, -1);// wait here for next event if (_event != IntPtr.Zero) { if (Common.bps_event_get_code(_event) == NAVIGATOR_CHILD_CARD_CLOSED) { IntPtr reasonPtr = Common.navigator_event_get_card_closed_reason(_event); string reason = Marshal.PtrToStringAnsi(reasonPtr); Debug.Log("reason: " + reason); if (reason == "save")//save - cancel { IntPtr dataPathPtr = Common.navigator_event_get_card_closed_data(_event); string dataPath = Marshal.PtrToStringAnsi(dataPathPtr); Debug.Log("Loading file from dataPath: " + dataPath); try { System.Text.RegularExpressions.MatchCollection matches = null; foreach (var pattern in dataPathPatterns) { matches = System.Text.RegularExpressions.Regex.Matches(dataPath, pattern); if (matches.Count != 0) break; } if (matches != null) foreach (System.Text.RegularExpressions.Match match in matches) { if (match.Groups.Count == 3) { string path = match.Groups[1].Value; string fileName = match.Groups[2].Value; // check for valid file type bool pass = false; foreach (var type in fileTypes) { if (Path.GetExtension(fileName) == type) { pass = true; break; } } if (!pass) throw new Exception("Invalid file ext."); // load file MemoryStream stream = null; using (var file = new FileStream(path+fileName, FileMode.Open, FileAccess.Read)) { if (maxWidth != 0 && maxHeight != 0) { ImageTools.IO.IImageDecoder decoder = null; switch (Path.GetExtension(fileName).ToLower()) { case ".jpg": decoder = new ImageTools.IO.Jpeg.JpegDecoder(); break; case ".jpeg": decoder = new ImageTools.IO.Jpeg.JpegDecoder(); break; case ".png": decoder = new ImageTools.IO.Png.PngDecoder(); break; default: Debug.LogError("Unsuported file ext type: " + Path.GetExtension(fileName)); streamLoadedCallback(null, false); return; } var image = new ImageTools.ExtendedImage(); decoder.Decode(image, file); var newSize = MathUtilities.FitInViewIfLarger(image.PixelWidth, image.PixelHeight, maxWidth, maxHeight); var newImage = ImageTools.ExtendedImage.Resize(image, (int)newSize.x, (int)newSize.y, new ImageTools.Filtering.NearestNeighborResizer()); var encoder = new ImageTools.IO.Jpeg.JpegEncoder(); stream = new MemoryStream(); encoder.Encode(newImage, stream); stream.Position = 0; /*unsafe { IntPtr ilib = IntPtr.Zero; if (img_lib_attach(&ilib) != 0) { Debug.LogError("Failed: img_lib_attach"); streamLoadedCallback(null, false); return; } img_t image = new img_t(); image.flags = 0x00000002; image.format = 32 | 0x00000100 | 0x00001000; img_decode_callouts_t callouts = new img_decode_callouts_t(); if (img_load_file(ilib, "file://"+path+fileName, &callouts, &image) != 0) { img_t newImage = new img_t(); if (img_resize_fs(&image, &newImage) != 0) { Debug.LogError("Failed: img_resize_fs"); streamLoadedCallback(null, false); return; } Debug.Log("WIDTH: " + image.w); Debug.Log("HEIGHT: " + image.h); streamLoadedCallback(null, false); return; //byte* data = (byte*)newImage.data.ToPointer(); //byte[] managedData = new byte[newImage.stride]; //stream = new MemoryStream(); } else { Debug.LogError("Failed to load image file: " + path + fileName); streamLoadedCallback(null, false); return; } img_lib_detach(ilib); }*/ } else { var data = new byte[file.Length]; file.Read(data, 0, data.Length); stream = new MemoryStream(data); stream.Position = 0; } } streamLoadedCallback(stream, true); return; } else { throw new Exception("Invalid dataPath."); } } } catch (Exception e) { Debug.LogError(e.Message); } streamLoadedCallback(null, false); } else { streamLoadedCallback(null, false); } break; } } } }
public override void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { streamFileLoadedCallback = streamLoadedCallback; LoadCameraPicker(maxWidth, maxHeight); }
private async void loadFileDialogAsync(FolderLocations folderLocation, int maxWidth, int maxHeight, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) #endif { #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(async delegate() #elif UNITY_WP_8_1 await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() #endif { Stream stream = null; try { #if WINDOWS_PHONE if (folderLocation == FolderLocations.Pictures) { photoChooser = new PhotoChooserTask(); photoChooser.ShowCamera = false; photoChooser.Completed += photoChooserTask_Completed; photoChooserTask_StreamLoadedCallback = streamLoadedCallback; photoChooserTask_fileTypes = fileTypes; photoChooserTask_maxWidth = maxWidth; photoChooserTask_maxHeight = maxHeight; photoChooser.Show(); return; } #endif var picker = new FileOpenPicker(); if (fileTypes != null) { foreach (var fileType in fileTypes) { picker.FileTypeFilter.Add(fileType); } } picker.SuggestedStartLocation = getFolderType(folderLocation); #if UNITY_WP_8_1 LoadFileDialog_picker = picker; LoadFileDialog_streamLoadedCallback = streamLoadedCallback; LoadFileDialog_maxWidth = maxWidth; LoadFileDialog_maxHeight = maxHeight; picker.PickSingleFileAndContinue(); #else var file = await picker.PickSingleFileAsync(); if (file != null) { if (maxWidth == 0 || maxHeight == 0) { stream = await file.OpenStreamForReadAsync(); UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(stream, true); }, false); } else { #if UNITY_METRO using (var tempStream = await file.OpenStreamForReadAsync()) { #if UNITY_METRO_8_0 using (var outputStream = new MemoryStream().AsOutputStream()) { await RandomAccessStream.CopyAsync(tempStream.AsInputStream(), outputStream); stream = await resizeImageStream((IRandomAccessStream)outputStream, maxWidth, maxHeight); } #else stream = await resizeImageStream(tempStream.AsRandomAccessStream(), maxWidth, maxHeight); #endif } UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(stream, true); }, false); #endif } } else { UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(null, false); }, false); } #endif } catch (Exception e) { if (stream != null) { stream.Dispose(); } Debug.LogError(e.Message); UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(null, false); }, false); } }); }
private async void loadCameraPickerAsync(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) #endif { #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(delegate() { loadCameraPicker_streamLoadedCallback = streamLoadedCallback; loadCameraPicker_maxWidth = maxWidth; loadCameraPicker_maxHeight = maxHeight; var cameraCaptureTask = new CameraCaptureTask(); cameraCaptureTask.Completed += new EventHandler <PhotoResult>(cameraCaptureTask_Completed); cameraCaptureTask.Show(); }); #elif UNITY_WP_8_1 loadFileDialogAsync(FolderLocations.Pictures, maxWidth, maxHeight, new string[] { ".jpg" }, streamLoadedCallback); #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() { try { var cameraUI = new CameraCaptureUI(); cameraUI.PhotoSettings.AllowCropping = false; switch (quality) { case CameraQuality.Low: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.SmallVga; break; case CameraQuality.Med: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.MediumXga; break; case CameraQuality.High: cameraUI.PhotoSettings.MaxResolution = CameraCaptureUIMaxPhotoResolution.HighestAvailable; break; } var capturedMedia = await cameraUI.CaptureFileAsync(CameraCaptureUIMode.Photo); if (capturedMedia != null) { using (var cameraStream = await capturedMedia.OpenAsync(FileAccessMode.Read)) { if (maxWidth == 0 || maxHeight == 0) { UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(cameraStream.AsStream(), true); }, false); } else { var stream = await resizeImageStream(cameraStream, maxWidth, maxHeight); UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(stream, true); }, false); } } } else { UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(null, false); }, false); } } catch (Exception e) { Debug.LogError(e.Message); UnityEngine.WSA.Application.InvokeOnAppThread(() => { streamLoadedCallback(null, false); }, false); } }); #endif }
public void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback != null) { streamLoadedCallback(null, false); } }
public void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) return; loadFileAsync(fileName, folderLocation, streamLoadedCallback); }
public void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) return; loadFileDialogAsync(folderLocation, maxWidth, maxHeight, fileTypes, streamLoadedCallback); }
public override void LoadCameraPicker (CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { streamFileLoadedCallback = streamLoadedCallback; LoadCameraPicker(maxWidth, maxHeight); }
public virtual void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { Debug.LogError("LoadFileDialog not supported on this Platform!"); if (streamLoadedCallback != null) { streamLoadedCallback(null, false); } }
public void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback != null) { streamLoadedCallback(null, false); } }
public override void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (folderLocation != FolderLocations.Pictures) { Debug.LogError("LoadFileDialog not supported for folder location: " + folderLocation + " on this Platform yet."); streamLoadedCallback(null, false); } else { if (Common.navigator_invoke_invocation_create(ref invoke) != 0) { return; } if (Common.navigator_invoke_invocation_set_target(invoke, "sys.filepicker.target") != 0) // sys.filesaver.target << use for file save dialog { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_action(invoke, "bb.action.OPEN") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_type(invoke, "application/vnd.blackberry.file_picker") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_send(invoke) != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } var dataPathPatterns = new string[] { @"file\://(/accounts/1000/shared/photos/)([\w|\.|\-]*)", @"file\://(/accounts/1000/shared/camera/)([\w|\.|\-]*)", @"file\://(/accounts/1000/shared/downloads/)([\w|\.|\-]*)" }; waitAndProcessImage(addUppers(fileTypes), dataPathPatterns, maxWidth, maxHeight, streamLoadedCallback); Common.navigator_invoke_invocation_destroy(invoke); } }
private async void loadFileAsync(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { Stream stream = null; try { #if WINDOWS_PHONE if (folderLocation == FolderLocations.Pictures) { using (var m = new MediaLibrary()) { foreach (var p in m.Pictures) { if (p.Name == fileName) { streamLoadedCallback(p.GetImage(), true); p.Dispose(); return; } else { p.Dispose(); } } } streamLoadedCallback(null, false); return; } #endif fileName = fileName.Replace('/', '\\'); stream = await openStream(fileName, folderLocation); } catch (Exception e) { if (stream != null) stream.Dispose(); Debug.LogError(e.Message); streamLoadedCallback(null, false); return; } streamLoadedCallback(stream, stream != null); }
public override void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { if (Common.navigator_invoke_invocation_create(ref invoke) != 0) { return; } if (Common.navigator_invoke_invocation_set_target(invoke, "sys.camera.card") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_action(invoke, "bb.action.CAPTURE") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_set_type(invoke, "image/jpeg") != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } string name = "photo"; IntPtr namePtr = Marshal.StringToHGlobalAnsi(name); if (Common.navigator_invoke_invocation_set_data(invoke, namePtr, name.Length) != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } if (Common.navigator_invoke_invocation_send(invoke) != 0) { Common.navigator_invoke_invocation_destroy(invoke); return; } var fileTypes = new string[] { ".jpg", "jpeg", ".png" }; var dataPathPatterns = new string[] { @"(/accounts/1000/shared/camera/)([\w|\.|\-]*)", @"(/accounts/1000/shared/photos/)([\w|\.|\-]*)" }; waitAndProcessImage(addUppers(fileTypes), dataPathPatterns, maxWidth, maxHeight, streamLoadedCallback); Common.navigator_invoke_invocation_destroy(invoke); Marshal.FreeHGlobal(namePtr); }
void photoChooserTask_Completed(object sender, PhotoResult e) { var callback = photoChooserTask_StreamLoadedCallback; var fileTypes = photoChooserTask_fileTypes; int maxWidth = photoChooserTask_maxWidth, maxHeight = photoChooserTask_maxHeight; photoChooserTask_StreamLoadedCallback = null; photoChooserTask_fileTypes = null; photoChooser = null; if (e.TaskResult != TaskResult.OK) { ReignServices.InvokeOnUnityThread(delegate { if (callback != null) callback(null, false); }); return; } string fileExt = getFileExt(e.OriginalFileName).ToLower(); foreach (var type in fileTypes) { if (getFileExt(type).ToLower() == fileExt) { if (callback != null && e.TaskResult == TaskResult.OK) { var stream = e.ChosenPhoto; if (maxWidth == 0 || maxHeight == 0) { ReignServices.InvokeOnUnityThread(delegate { callback(stream, true); }); } else { var scaledStream = resizeImageStream(stream, maxWidth, maxHeight); ReignServices.InvokeOnUnityThread(delegate { callback(scaledStream, true); }); } } else if (callback != null) { ReignServices.InvokeOnUnityThread(delegate { callback(null, false); }); } return; } } ReignServices.InvokeOnUnityThread(delegate { if (callback != null) callback(null, false); }); }
private static void waitAndProcessImage(string[] fileTypes, string[] dataPathPatterns, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { // wait for event while (true) { IntPtr _event = IntPtr.Zero; Common.bps_get_event(ref _event, -1); // wait here for next event if (_event != IntPtr.Zero) { if (Common.bps_event_get_code(_event) == NAVIGATOR_CHILD_CARD_CLOSED) { IntPtr reasonPtr = Common.navigator_event_get_card_closed_reason(_event); string reason = Marshal.PtrToStringAnsi(reasonPtr); Debug.Log("reason: " + reason); if (reason == "save") //save - cancel { IntPtr dataPathPtr = Common.navigator_event_get_card_closed_data(_event); string dataPath = Marshal.PtrToStringAnsi(dataPathPtr); Debug.Log("Loading file from dataPath: " + dataPath); try { System.Text.RegularExpressions.MatchCollection matches = null; foreach (var pattern in dataPathPatterns) { matches = System.Text.RegularExpressions.Regex.Matches(dataPath, pattern); if (matches.Count != 0) { break; } } if (matches != null) { foreach (System.Text.RegularExpressions.Match match in matches) { if (match.Groups.Count == 3) { string path = match.Groups[1].Value; string fileName = match.Groups[2].Value; // check for valid file type bool pass = false; foreach (var type in fileTypes) { if (Path.GetExtension(fileName) == type) { pass = true; break; } } if (!pass) { throw new Exception("Invalid file ext."); } // load file MemoryStream stream = null; using (var file = new FileStream(path + fileName, FileMode.Open, FileAccess.Read)) { if (maxWidth != 0 && maxHeight != 0) { ImageTools.IO.IImageDecoder decoder = null; switch (Path.GetExtension(fileName).ToLower()) { case ".jpg": decoder = new ImageTools.IO.Jpeg.JpegDecoder(); break; case ".jpeg": decoder = new ImageTools.IO.Jpeg.JpegDecoder(); break; case ".png": decoder = new ImageTools.IO.Png.PngDecoder(); break; default: Debug.LogError("Unsuported file ext type: " + Path.GetExtension(fileName)); streamLoadedCallback(null, false); return; } var image = new ImageTools.ExtendedImage(); decoder.Decode(image, file); var newSize = MathUtilities.FitInViewIfLarger(image.PixelWidth, image.PixelHeight, maxWidth, maxHeight); var newImage = ImageTools.ExtendedImage.Resize(image, (int)newSize.x, (int)newSize.y, new ImageTools.Filtering.NearestNeighborResizer()); var encoder = new ImageTools.IO.Jpeg.JpegEncoder(); stream = new MemoryStream(); encoder.Encode(newImage, stream); stream.Position = 0; /*unsafe * { * IntPtr ilib = IntPtr.Zero; * if (img_lib_attach(&ilib) != 0) * { * Debug.LogError("Failed: img_lib_attach"); * streamLoadedCallback(null, false); * return; * } * * img_t image = new img_t(); * image.flags = 0x00000002; * image.format = 32 | 0x00000100 | 0x00001000; * img_decode_callouts_t callouts = new img_decode_callouts_t(); * if (img_load_file(ilib, "file://"+path+fileName, &callouts, &image) != 0) * { * img_t newImage = new img_t(); * if (img_resize_fs(&image, &newImage) != 0) * { * Debug.LogError("Failed: img_resize_fs"); * streamLoadedCallback(null, false); * return; * } * * Debug.Log("WIDTH: " + image.w); * Debug.Log("HEIGHT: " + image.h); * streamLoadedCallback(null, false); * return; * //byte* data = (byte*)newImage.data.ToPointer(); * //byte[] managedData = new byte[newImage.stride]; * * //stream = new MemoryStream(); * } * else * { * Debug.LogError("Failed to load image file: " + path + fileName); * streamLoadedCallback(null, false); * return; * } * * img_lib_detach(ilib); * }*/ } else { var data = new byte[file.Length]; file.Read(data, 0, data.Length); stream = new MemoryStream(data); stream.Position = 0; } } streamLoadedCallback(stream, true); return; } else { throw new Exception("Invalid dataPath."); } } } } catch (Exception e) { Debug.LogError(e.Message); } streamLoadedCallback(null, false); } else { streamLoadedCallback(null, false); } break; } } } }
private async void loadFileDialogAsync(FolderLocations folderLocation, int maxWidth, int maxHeight, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) #endif { #if WINDOWS_PHONE WinRTPlugin.Dispatcher.BeginInvoke(async delegate() #elif UNITY_WP_8_1 await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, delegate() #else await WinRTPlugin.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async delegate() #endif { Stream stream = null; try { #if WINDOWS_PHONE if (folderLocation == FolderLocations.Pictures) { photoChooser = new PhotoChooserTask(); photoChooser.ShowCamera = false; photoChooser.Completed += photoChooserTask_Completed; photoChooserTask_StreamLoadedCallback = streamLoadedCallback; photoChooserTask_fileTypes = fileTypes; photoChooserTask_maxWidth = maxWidth; photoChooserTask_maxHeight = maxHeight; photoChooser.Show(); return; } #endif var picker = new FileOpenPicker(); if (fileTypes != null) { foreach (var fileType in fileTypes) picker.FileTypeFilter.Add(fileType); } picker.SuggestedStartLocation = getFolderType(folderLocation); #if UNITY_WP_8_1 LoadFileDialog_picker = picker; LoadFileDialog_streamLoadedCallback = streamLoadedCallback; LoadFileDialog_maxWidth = maxWidth; LoadFileDialog_maxHeight = maxHeight; picker.PickSingleFileAndContinue(); #else var file = await picker.PickSingleFileAsync(); if (file != null) { if (maxWidth == 0 || maxHeight == 0) { stream = await file.OpenStreamForReadAsync(); ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(stream, true); }); } else { #if UNITY_METRO using (var tempStream = await file.OpenStreamForReadAsync()) { #if UNITY_METRO_8_0 using (var outputStream = new MemoryStream().AsOutputStream()) { await RandomAccessStream.CopyAsync(tempStream.AsInputStream(), outputStream); stream = await resizeImageStream((IRandomAccessStream)outputStream, maxWidth, maxHeight); } #else stream = await resizeImageStream(tempStream.AsRandomAccessStream(), maxWidth, maxHeight); #endif } ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(stream, true); }); #endif } } else { ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(null, false); }); } #endif } catch (Exception e) { if (stream != null) stream.Dispose(); Debug.LogError(e.Message); ReignServices.InvokeOnUnityThread(delegate { streamLoadedCallback(null, false); }); } }); }
public virtual void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { Debug.LogError("LoadFileDialog not supported on this Platform!"); if (streamLoadedCallback != null) streamLoadedCallback(null, false); }
public void LoadFile(string fileName, FolderLocations folderLocation, StreamLoadedCallbackMethod streamLoadedCallback) { Native.LoadFile(fileName, folderLocation, streamLoadedCallback); }
public virtual void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { Debug.LogError("LoadCameraPicker not supported on this Platform!"); if (streamLoadedCallback != null) streamLoadedCallback(null, false); }
public void LoadCameraPicker(CameraQuality quality, int maxWidth, int maxHeight, StreamLoadedCallbackMethod streamLoadedCallback) { Native.LoadCameraPicker(quality, maxWidth, maxHeight, streamLoadedCallback); }
public override void LoadFileDialog(FolderLocations folderLocation, int maxWidth, int maxHeight, int x, int y, int width, int height, string[] fileTypes, StreamLoadedCallbackMethod streamLoadedCallback) { if (streamLoadedCallback == null) { return; } string filename = EditorUtility.OpenFilePanel("Load file", "", generateFilterValue(fileTypes)); if (!string.IsNullOrEmpty(filename)) { if (maxWidth == 0 || maxHeight == 0 || folderLocation != FolderLocations.Pictures) { streamLoadedCallback(new FileStream(filename, FileMode.Open, FileAccess.Read), true); } else { var newStream = new MemoryStream(); try { using (var stream = new FileStream(filename, FileMode.Open, FileAccess.Read)) { IImageDecoder decoder = null; switch (Path.GetExtension(filename).ToLower()) { case ".jpg": decoder = new JpegDecoder(); break; case ".jpeg": decoder = new JpegDecoder(); break; case ".png": decoder = new PngDecoder(); break; default: Debug.LogError("Unsuported file ext type: " + Path.GetExtension(filename)); streamLoadedCallback(null, false); return; } var image = new ExtendedImage(); decoder.Decode(image, stream); var newSize = MathUtilities.FitInViewIfLarger(image.PixelWidth, image.PixelHeight, maxWidth, maxHeight); var newImage = ExtendedImage.Resize(image, (int)newSize.x, (int)newSize.y, new NearestNeighborResizer()); var encoder = new PngEncoder(); encoder.Encode(newImage, newStream); newStream.Position = 0; } } catch (Exception e) { newStream.Dispose(); newStream = null; Debug.LogError(e.Message); } finally { streamLoadedCallback(newStream, true); } } } else { streamLoadedCallback(null, false); } }