public unsafe int AddMetric(string tag, float minimumValue, float maximumValue, int sampleCount, Func <float> getCurrentValue) { int id; fixed(byte *tagBytes = ResourceLoader.GetBytes(tag)) { id = DllImports.AddGraph(new DllImports.GraphData() { tag = tagBytes, tagLen = tag.Length, minVal = minimumValue, maxVal = maximumValue, valuesCount = sampleCount }); } if (id <= DllImports.FpsGraphId) { return(DllImports.WrongGraphId); } _metrics.Add(new Metric { Id = id, Update = getCurrentValue }); DllImports.SetGraphVisibility(id, _metricsShown ? 1 : 0); return(id); }
protected override bool OnUpdate() { UpdateUI(); NativeActions.GetInstance().Execute(); DllImports.Draw(); return(true); }
public override unsafe void Push() { fixed(byte *p = _data) { DllImports.AddFont(p, _data.Length); } }
private void HandleExternalTileSelection(string url) { _startedFromDeepLink = true; var tileNo = _resourceLoader.ContentList.FindIndex(content => string.Equals(content.Url, url, StringComparison.OrdinalIgnoreCase)); if (tileNo < 0) { return; } if (tileNo == _selectedTile) { return; } if (Player != null) { ClosePlayer(); } _selectedTile = tileNo; DllImports.SelectTile(_selectedTile); if (_resourceLoader.IsLoadingFinished) { HandleExternalPlaybackStart(); } }
private unsafe void UpdatePlaybackControls() { if (_seekBufferingInProgress == false && _seekInProgress == false) { _playerTimeCurrentPosition = _player?.CurrentPosition ?? TimeSpan.Zero; } _playerTimeDuration = _player?.Duration ?? TimeSpan.Zero; if (_progressBarShown && _player?.State == PlayerState.Playing && (DateTime.Now - _lastKeyPressTime).TotalMilliseconds >= _progressBarFadeout.TotalMilliseconds) { _progressBarShown = false; _options.Hide(); Logger?.Info( $"{(DateTime.Now - _lastKeyPressTime).TotalMilliseconds} ms of inactivity, hiding progress bar."); } fixed(byte *name = ResourceLoader.GetBytes(_resourceLoader.ContentList[_selectedTile].Title)) { DllImports.UpdatePlaybackControls(new DllImports.PlaybackData() { show = _progressBarShown ? 1 : 0, state = (int)(_player?.State ?? PlayerState.Idle), currentTime = (int)_playerTimeCurrentPosition.TotalMilliseconds, totalTime = (int)_playerTimeDuration.TotalMilliseconds, text = name, textLen = _resourceLoader.ContentList[_selectedTile].Title.Length, buffering = _bufferingInProgress ? 1 : 0, bufferingPercent = _bufferingProgress }); } }
private void HandleKeyReturn() { if (_isAlertShown) { DllImports.HideAlert(); _isAlertShown = false; } else if (_isMenuShown) { if (_selectedTile >= _resourceLoader.TilesCount) { return; } ShowMenu(false); HandlePlaybackStart(); } else if (_progressBarShown && !_options.Visible) { switch (Player.State) { case Common.PlayerState.Playing: Player?.Pause(); break; case Common.PlayerState.Paused: Player?.Start(); break; } } else if (_options.Visible && _options.ProperSelection()) { _options.ControlSelect(Player); _options.Hide(); } }
private unsafe void UpdatePlaybackControls() { if (_progressBarShown && Player?.State == Common.PlayerState.Playing && (DateTime.Now - _lastKeyPressTime).TotalMilliseconds >= _progressBarFadeout.TotalMilliseconds) { _progressBarShown = false; _options.Hide(); Logger?.Info( $"{(DateTime.Now - _lastKeyPressTime).TotalMilliseconds} ms of inactivity, hiding progress bar."); } fixed(byte *name = ResourceLoader.GetBytes(_resourceLoader.ContentList[_selectedTile].Title)) { DllImports.UpdatePlaybackControls(new DllImports.PlaybackData() { show = _progressBarShown ? 1 : 0, state = (int)ToPlayerState(Player?.State ?? Common.PlayerState.Idle), currentTime = (int)_seekLogic.CurrentPositionUI.TotalMilliseconds, totalTime = (int)_seekLogic.Duration.TotalMilliseconds, text = name, textLen = _resourceLoader.ContentList[_selectedTile].Title.Length, buffering = _bufferingInProgress ? 1 : 0, bufferingPercent = _bufferingProgress, seeking = (_seekLogic.IsSeekInProgress || _seekLogic.IsSeekAccumulationInProgress) ? 1 : 0 }); } }
public void Update() { foreach (Metric metric in _metrics) { DllImports.UpdateGraphValue(metric.Id, metric.Update()); } }
protected override void OnCreate() { _uiContext = SynchronizationContext.Current; OpenGLLoggerManager.Configure(_uiContext); DllImports.Create(); InitMenu(); }
public void SetSeekPreviewReader(StoryboardReader storyboardReader, SeekLogic seekLogic) { _seekPreviewReader?.Dispose(); _seekPreviewReader = storyboardReader; seekLogic.StoryboardReader = _seekPreviewReader; DllImports.SetSeekPreviewCallback(_getSeekPreviewStoryboardDelegate); _seekLogic = seekLogic; }
private void LoadTiles(string dirPath) { _resourcesTargetCount += ContentList.Count; foreach (var contentItem in ContentList) { LoadAndSchedule(new TileResource(DllImports.AddTile(), Path.Combine(dirPath, "tiles", contentItem.Poster), contentItem.Title ?? "", contentItem.Description ?? "")); } }
private static unsafe void SetMenuFooter() { string footer = $"JuvoPlayer v{typeof(Program).Assembly.GetName().Version.Major}.{typeof(Program).Assembly.GetName().Version.Minor}.{typeof(Program).Assembly.GetName().Version.Build}, OpenGL Native #{DllImports.OpenGLLibVersion():x}, Samsung R&D Poland 2017-{DateTime.Now.Year}"; fixed(byte *f = ResourceLoader.GetBytes(footer)) DllImports.SetFooter(f, footer.Length); }
private unsafe void UpdateSubtitles() { if (Player?.CurrentCueText != null && _options.SubtitlesOn) { fixed(byte *cueText = ResourceLoader.GetBytes(Player.CurrentCueText)) DllImports.ShowSubtitle(0, cueText, Player.CurrentCueText.Length); // 0ms duration - special value just for next frame } }
private void UpdateState() { DllImports.SetGraphVisibility(DllImports.FpsGraphId, _metricsShown ? 1 : 0); foreach (Metric metric in _metrics) { DllImports.SetGraphVisibility(metric.Id, _metricsShown ? 1 : 0); } DllImports.SetLogConsoleVisibility(_metricsShown ? 1 : 0); }
protected override void OnCreate() { _uiContext = SynchronizationContext.Current; OpenGlLoggerManager.Configure(_uiContext); _seekLogic = new SeekLogic(this); DllImports.Create(); InitializeKeyHandlersMap(); InitMenu(); }
private void ShowMenu(bool show) { if (show == _isMenuShown) { return; } _isMenuShown = show; DllImports.ShowMenu(_isMenuShown ? 1 : 0); }
public void ClearOptionsMenu() { _activeOption = -1; _activeSubOption = -1; _selectedOption = -1; _selectedSubOption = -1; Visible = false; SubtitlesOn = false; _streams = new List <StreamDescriptionsList>(); DllImports.ClearOptions(); }
private void ShowMenu(bool show) { if (show == _isMenuShown) { Logger.Info($"ShowMenu({show}) dupe, ignoring."); return; } _isMenuShown = show; DllImports.ShowMenu(_isMenuShown ? 1 : 0); }
private void SetDefaultMenuState() { _isMenuShown = false; DllImports.ShowLoader(1, 0); _lastKeyPressTime = DateTime.Now; _seekLogic.Reset(); _playbackCompletedNeedsHandling = false; _metricsHandler.Hide(); }
public override unsafe void Push() { fixed(byte *p = _image.Pixels) { DllImports.SetIcon(new DllImports.ImageData { id = (int)_type, pixels = p, width = _image.Width, height = _image.Height, format = (int)_image.Format }); } }
private void SetDefaultMenuState() { _selectedTile = 0; DllImports.SelectTile(_selectedTile); _isMenuShown = false; DllImports.ShowLoader(1, 0); _lastKeyPressTime = DateTime.Now; _seekLogic.Reset(); CurrentPositionUI = TimeSpan.Zero; _playbackCompletedNeedsHandling = false; _metricsHandler.Hide(); }
private void ShowMenu(bool show) { if (show == _isMenuShown) { return; } if (!show) { StoryboardManager.GetInstance().UnloadTilePreview(); } _isMenuShown = show; DllImports.ShowMenu(_isMenuShown ? 1 : 0); }
private void UpdateOptionsSelection() { Logger?.Info($"activeOption={_activeOption}, activeSubOption={_activeSubOption}, selectedOption={_selectedOption}, selectedSubOption={_selectedSubOption}"); if (_selectedOption >= 0 && _selectedOption < _streams.Count) { _activeSubOption = _streams[_selectedOption].Active; } DllImports.UpdateSelection(new DllImports.SelectionData() { show = Visible ? 1 : 0, activeOptionId = _activeOption, activeSubOptionId = _activeSubOption, selectedOptionId = _selectedOption, selectedSubOptionId = _selectedSubOption }); }
private unsafe void ShowAlert(string title, string body, string button) { fixed(byte *titleBytes = ResourceLoader.GetBytes(title), bodyBytes = ResourceLoader.GetBytes(body), buttonBytes = ResourceLoader.GetBytes(button)) { DllImports.ShowAlert(new DllImports.AlertData() { title = titleBytes, titleLen = title.Length, body = bodyBytes, bodyLen = body.Length, button = buttonBytes, buttonLen = button.Length }); } _isAlertShown = true; }
private void HandleExternalTileSelection() { var tileNo = _resourceLoader.ContentList.FindIndex(content => string.Equals(content.Url, _deepLinkUrl, StringComparison.OrdinalIgnoreCase)); _deepLinkUrl = ""; if (tileNo == -1 || tileNo == _selectedTile) { return; } if (Player != null) { ClosePlayer(); } _selectedTile = tileNo; DllImports.SelectTile(_selectedTile, 0); HandleExternalPlaybackStart(); }
public override unsafe void Push() { fixed(byte *p = _image.Pixels, name = GetBytes(_name), desc = GetBytes(_description)) { DllImports.SetTileData(new DllImports.TileData { tileId = _id, pixels = p, width = _image.Width, height = _image.Height, name = name, nameLen = _name.Length, desc = desc, descLen = _description.Length, format = (int)_image.Format, getStoryboardData = StoryboardManager.GetInstance().AddTile(_id) }); } }
private void HandleKeyRight() { if (_isMenuShown) { if (_selectedTile < _resourceLoader.TilesCount - 1) { _selectedTile = (_selectedTile + 1) % _resourceLoader.TilesCount; } DllImports.SelectTile(_selectedTile); } else if (_options.Visible) { _options.ControlRight(); } else if (_progressBarShown) { _seekLogic.SeekForward(); } }
private void HandleKeyLeft() { if (_isMenuShown) { if (_selectedTile > 0) { _selectedTile = (_selectedTile - 1 + _resourceLoader.TilesCount) % _resourceLoader.TilesCount; } DllImports.SelectTile(_selectedTile); } else if (_options.Visible) { _options.ControlLeft(); } else if (_progressBarShown) { _seekLogic.SeekBackward(); } }
private async void SetLoaderLogo(string path) { var imageData = await Resource.GetImage(path); NativeActions.GetInstance().Enqueue(() => { unsafe { fixed(byte *pixels = imageData.Pixels) DllImports.SetLoaderLogo(new DllImports.ImageData { id = 0, pixels = pixels, width = imageData.Width, height = imageData.Height, format = (int)imageData.Format }); } }); }
private void HandleLoadingFinished() { _playerWindow = new Window("JuvoPlayer") { Geometry = new Rect(0, 0, 1920, 1080) }; _playerWindow.Show(); _playerWindow.Lower(); if (!_deepLinkUrl.Equals("")) { HandleExternalTileSelection(); } else { _selectedTile = 0; DllImports.SelectTile(_selectedTile, 0); ShowMenu(true); } }