private void Start() { _mediaPlayer.VideoSource = _url; _mediaPlayer.LicenseServer = _licenseUrl; if (_customLicenseHeaderData != null && _customLicenseHeaderData.Length > 0) { Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (StringKeyValue pair in _customLicenseHeaderData) { if (!String.IsNullOrEmpty(pair.Key) && !String.IsNullOrEmpty(pair.Value)) { dict[pair.Key] = pair.Value; } } _mediaPlayer.CustomLicenseHeaderData = dict; } MLResult result = _mediaPlayer.PrepareVideo(); if (!result.IsOk) { _statusText.text = result.ToString(); } EnableUI(false); _timelineSlider.Value = 0; }
private void Start() { _mediaPlayer.VideoRenderMaterial = _videoRenderMaterial; _mediaPlayer.StereoMode = _stereoMode; _mediaPlayer.VideoSource = _url; _mediaPlayer.LicenseServer = _licenseUrl; _mediaPlayer.IsLooping = _autoLoop; if (_customLicenseHeaderData != null && _customLicenseHeaderData.Length > 0) { Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (StringKeyValue pair in _customLicenseHeaderData) { if (!String.IsNullOrEmpty(pair.Key) && !String.IsNullOrEmpty(pair.Value)) { dict[pair.Key] = pair.Value; } } _mediaPlayer.CustomLicenseHeaderData = dict; } MLResult result = _mediaPlayer.PrepareVideo(); if (!result.IsOk) { if (result.Code == MLResultCode.PrivilegeDenied) { Instantiate(Resources.Load("PrivilegeDeniedError")); } _statusText.text = result.ToString(); } EnableUI(false); _timelineSlider.Value = 0; }
private void Start() { _mediaPlayer.VideoSource = _url; _mediaPlayer.LicenseServer = _licenseUrl; MLResult result = _mediaPlayer.PrepareVideo(); if (!result.IsOk) { _statusText.text = result.ToString(); } EnableUI(false); _timelineSlider.Value = 0; }
/// <summary> /// Handler when the user wants to save the contact. /// Main Controller determines if this is an add or update operation. /// </summary> private void HandleSaveEdit() { UpdateContactFromFields(); MLResult contactResult = _mainController.ValidateContact(_contact); if (!contactResult.IsOk) { _mainController.Log(string.Format("<color=red>{0}</color>", contactResult.ToString())); return; } _mainController.SaveContact(_contact); // leave the page, _mainController will update the // page depending on the result of operation }
/// <summary> /// Handler when the user wants to save the contact. /// </summary> private void HandleSaveEdit() { UpdateContactFromFields(); #if PLATFORM_LUMIN MLResult contactResult = MLContacts.ValidateContact(_contact); if (!contactResult.IsOk) { _visualizerStatusText.text = string.Format("<color=red>{0}</color>", contactResult.ToString()); return; } _contactsVisualizer.Contacts.SaveContact(_contact); #endif // leave the page, the MLContactsBehavior will update the // page depending on the result of operation }
/// <summary> /// Handler when privileges have been requested. /// </summary> /// <param name="result">Result of the operation</param> private void HandlePrivilegesDone(MLResult result) { if (!result.IsOk) { if (result.Code == MLResultCode.PrivilegeDenied) { Instantiate(Resources.Load("PrivilegeDeniedError")); } Log("<color=red>Privileges Error: " + result.ToString() + "</color>"); Debug.LogErrorFormat("Error: ContactsExample failed to get requested privileges, disabling script. Reason: {0}", result); enabled = false; return; } Log("<color=green>Privileges Granted</color>"); StartupAPI(); }
/// <summary> /// Start this instance. /// </summary> void Start() { MLResult result = MLPersistentStore.Start(); if (!result.IsOk) { SetError("Failed to start persistent store. Disabling component"); enabled = false; return; } result = MLPersistentCoordinateFrames.Start(); if (!result.IsOk) { MLPersistentStore.Stop(); SetError("Failed to start coordinate frames system. disabling component"); enabled = false; return; } if (_representativePrefab == null) { SetError("Error: _representativePrefab must be set"); enabled = false; return; } List <MLPCF> pcfList; result = MLPersistentCoordinateFrames.GetAllPCFs(out pcfList, int.MaxValue); if (!result.IsOk) { MLPersistentStore.Stop(); MLPersistentCoordinateFrames.Stop(); SetError(result.ToString()); enabled = false; return; } TryShowingAllPCFs(pcfList); }
private void OnCaptureCompleted(MLCameraResultExtras extras, string extraString) { Matrix4x4 matrix4X4 = new Matrix4x4(); MLResult poseResult = MLCamera.GetFramePose(extras.VcamTimestampUs * 1000, out matrix4X4); Pose pose = new Pose { rotation = matrix4X4.rotation, translation = new Vector3(matrix4X4.m03, matrix4X4.m13, matrix4X4.m23) }; String info = String.Format("OnCaptureCompleted.\n Frame number: {0}, Frame time: {1}\nExtra String: {2}", extras.FrameNumber, extras.VcamTimestampUs, extraString); Debug.Log(info); Debug.Log(String.Format("========\n{4}\n{3}\n{0}\nrotation:{1}\ntranslation:{2}\n===========\n", matrix4X4, pose.rotation.ToString("f4"), pose.translation.ToString("f4"), poseResult, info)); _text.text = String.Format("Frame#{0}, FrameTime: {1}\nRotation:{2}\nTranslation:{3}", extras.FrameNumber, extras.VcamTimestampUs / 1000, pose.rotation.ToString("f4"), pose.translation.ToString("f4")); _results.images.Add(new ImageInfo { fileName = String.Format(@"image{0}.jpeg", _results.images.Count), timestampSec = ((double)extras.VcamTimestampUs) / 1000000.0d, poseStatus = poseResult.ToString(), framePose = pose, poseMatrix = matrix4X4 }); lock (_cameraLockObject) { _isCapturing = false; } if (_autoCapture) { TriggerAsyncCapture(); } else { GenerateJsonReport(); } }
/// <summary> /// Handler when page is retrieved successfully. Store the list of contacts in memory and /// fetch the next page. If this is the last page, display them. /// </summary> /// <param name="page">Page with list of contacts</param> private void RefreshListPageReady(MLContactsListPage page) { foreach (MLContactsContact contact in page.ContactsList) { _loadedContacts[contact.ID] = contact; } if (page.Status == MLContactsListPage.PageStatus.LastPage) { _listPage.PopulateList(new List <MLContactsContact>(_loadedContacts.Values)); } else { MLResult result = page.NextPage(); // automatically fetches the next page; triggering RefreshListPageReady when done or HandlePageFailed on failure if (!result.IsOk) { Log("<color=red>RefreshListPageReady() Error: " + result.ToString() + "</color>"); Debug.LogErrorFormat("Error: ContactsExample failed to request the next page while refreshing the list, disabling script. Reason was: {0}", result); enabled = false; return; } } }
/// <summary> /// Initialize MLMediaPlayer parameters and attempt prepare the video. /// </summary> private void Start() { #if PLATFORM_LUMIN _mediaPlayer.VideoRenderMaterial = _videoRenderMaterial; _mediaPlayer.StereoMode = _stereoMode; _mediaPlayer.VideoSource = _url; _mediaPlayer.LicenseServer = _licenseUrl; _mediaPlayer.IsLooping = _autoLoop; #endif if (_customLicenseHeaderData != null && _customLicenseHeaderData.Length > 0) { Dictionary <string, string> dict = new Dictionary <string, string>(); foreach (StringKeyValue pair in _customLicenseHeaderData) { if (!String.IsNullOrEmpty(pair.Key) && !String.IsNullOrEmpty(pair.Value)) { dict[pair.Key] = pair.Value; } } #if PLATFORM_LUMIN _mediaPlayer.CustomLicenseHeaderData = dict; #endif } #if PLATFORM_LUMIN MLResult result = _mediaPlayer.PrepareVideo(); if (!result.IsOk) { _statusText.text = result.ToString(); } #endif EnableUI(false); _timelineSlider.Value = 0; }