### Complete Examples Source: https://docs.rybena.com.br/docs/api/player-control Provides complete examples demonstrating various use cases of the Rybená API. ```APIDOC ### Example 1: Floating Player This example creates a player that can be moved to different positions: ```javascript RybenaApi.getInstance().handleLoaded(() => { // Show the player RybenaApi.getInstance().openPlayer(); // Position in the top-right corner RybenaApi.getInstance().setCoordinates( window.innerWidth - 420, 20 ); // Set smaller size RybenaApi.getInstance().setSize(0.8); }); ``` ``` ```APIDOC ### Example 2: Transparent Mode Player This example shows how to use transparent mode for a more immersive experience: ```javascript RybenaApi.getInstance().handleLoaded(() => { // Show the player RybenaApi.getInstance().openPlayer(); // Set transparent mode RybenaApi.getInstance().setToTransparentMode(); // Position in the center const centerX = window.innerWidth / 2 - 200; const centerY = window.innerHeight / 2 - 150; RybenaApi.getInstance().setCoordinates(centerX, centerY); // Translate a text RybenaApi.getInstance().translate("Welcome!"); }); ``` ``` ```APIDOC ### Example 3: Responsive Player This example adjusts the player's size and position based on the screen size: ```javascript function adjustPlayerForScreen() { const isMobile = window.innerWidth < 768; if (isMobile) { // Smaller size for mobile RybenaApi.getInstance().setSize(0.6); RybenaApi.getInstance().setCoordinates(10, 10); } else { // Normal size for desktop RybenaApi.getInstance().setSize(1.0); RybenaApi.getInstance().setCoordinates(20, 20); } } RybenaApi.getInstance().handleLoaded(() => { RybenaApi.getInstance().openPlayer(); adjustPlayerForScreen(); // Adjust when the window is resized window.addEventListener('resize', adjustPlayerForScreen); }); ``` ``` ```APIDOC ### Example 4: Visibility Toggle This example creates a button to toggle the player's visibility: ```javascript let isPlayerVisible = false; function togglePlayer() { if (isPlayerVisible) { RybenaApi.getInstance().closePlayer(); } else { RybenaApi.getInstance().openPlayer(); } isPlayerVisible = !isPlayerVisible; } RybenaApi.getInstance().handleLoaded(() => { // Configure button document.getElementById('togglePlayerBtn').addEventListener('click', togglePlayer); }); ``` ``` -------------------------------- ### Basic Initialization Example Source: https://docs.rybena.com.br/docs/api/event-handlers Demonstrates using handleLoaded to ensure the API is ready before opening the player and translating text. ```javascript RybenaApi.getInstance().handleLoaded(() => { console.log("Rybená API está pronta!"); // Mostra o player RybenaApi.getInstance().openPlayer(); // Traduz um texto RybenaApi.getInstance().translate("Olá, bem-vindo à Rybená!"); }); ``` -------------------------------- ### Initialize Rybena API on Load Source: https://docs.rybena.com.br/docs/api/accessibility-features Logs a message to the console once the Rybena API is loaded. This is a basic setup for confirming the API is ready. ```javascript RybenaApi.getInstance().handleLoaded(() => { console.log("Rybená carregada"); }); ``` -------------------------------- ### Minimalist Configuration Source: https://docs.rybena.com.br/docs/getting-started/configuration A compact player setup positioned on the right without the LIBRAS button. ```html ``` -------------------------------- ### Rybená Access Token URL Example Source: https://docs.rybena.com.br/docs/integrations/mobile-apps Shows how to construct the WebView URL for Rybená integration, including the necessary access token for authentication. ```javascript // URL da WebView com token const rybenaUrl = 'https://repository.rybena.com.br/webview/index.html?token=SEU-TOKEN-AQUI'; ``` -------------------------------- ### Translation State Verification Example Source: https://docs.rybena.com.br/docs/api/event-handlers Demonstrates checking the translation status immediately and after a delay. ```javascript RybenaApi.getInstance().handleLoaded(() => { RybenaApi.getInstance().openPlayer(); // Verifica se está traduzindo console.log("Está traduzindo:", RybenaApi.getInstance().isTranslating()); // Traduz um texto RybenaApi.getInstance().translate("Verificando estado..."); // Verifica novamente após 1 segundo setTimeout(() => { console.log("Está traduzindo:", RybenaApi.getInstance().isTranslating()); }, 1000); }); ``` -------------------------------- ### Sequential Translation Example Source: https://docs.rybena.com.br/docs/api/event-handlers Shows how to process an array of strings in sequence by chaining translation calls via the handleTranslate callback. ```javascript const texts = [ "Primeira frase", "Segunda frase", "Terceira frase" ]; let currentIndex = 0; function translateNext() { if (currentIndex < texts.length) { console.log("Traduzindo:", texts[currentIndex]); RybenaApi.getInstance().translate(texts[currentIndex]); currentIndex++; } else { console.log("Todas as traduções concluídas!"); } } RybenaApi.getInstance().handleLoaded(() => { RybenaApi.getInstance().openPlayer(); // Configura callback para traduzir o próximo texto RybenaApi.getInstance().handleTranslate(() => { translateNext(); }); // Começa a tradução translateNext(); }); ``` -------------------------------- ### Flutter Dependency Installation Source: https://docs.rybena.com.br/docs/integrations/mobile-apps Add the webview_flutter package to your pubspec.yaml file. ```yaml dependencies: webview_flutter: ^4.0.0 ``` -------------------------------- ### Initialization and Basic Usage Source: https://docs.rybena.com.br/docs/api How to initialize the Rybená script in API mode and perform basic operations like opening the player and translating text. ```APIDOC ## Initialization ### Description Initialize the Rybená script with the `mode=api` parameter to enable background operation and remove presentation texts. ### Request Example ## Basic Usage ### Description Use the singleton instance `RybenaApi.getInstance()` to control the player and trigger translations. ### Code Example // Aguarda a Rybená carregar RybenaApi.getInstance().handleLoaded(() => { // Mostra o player RybenaApi.getInstance().openPlayer(); // Traduz um texto RybenaApi.getInstance().translate("Olá, bem-vindo à Rybená!"); }); ``` -------------------------------- ### Exemplo Completo de Barra de Acessibilidade Customizada com Estilização Source: https://docs.rybena.com.br/docs/getting-started/customization Demonstração completa de uma barra de acessibilidade customizada, incluindo estilos CSS para a barra e seus botões. Note que ao usar uma barra customizada, configurações como 'positionBar' e 'backgroundColorBar' da barra padrão não terão efeito. ```html
``` -------------------------------- ### Translation Completion Callback Example Source: https://docs.rybena.com.br/docs/api/event-handlers Shows how to trigger code specifically after a translation operation finishes. ```javascript RybenaApi.getInstance().handleLoaded(() => { RybenaApi.getInstance().openPlayer(); // Configura callback para quando a tradução terminar RybenaApi.getInstance().handleTranslate(() => { console.log("Tradução concluída!"); alert("Tradução finalizada!"); }); // Traduz um texto RybenaApi.getInstance().translate("Este texto será traduzido"); }); ``` -------------------------------- ### GET /dom/master/latest/rybena.js Source: https://docs.rybena.com.br/docs/getting-started/configuration Configures the Rybená script behavior, appearance, and positioning using query parameters. ```APIDOC ## GET /dom/master/latest/rybena.js ### Description Configures the Rybená translation script by appending parameters to the script source URL. ### Method GET ### Endpoint https://cdn.rybena.com.br/dom/master/latest/rybena.js ### Parameters #### Query Parameters - **positionPlayer** (string) - Optional - Horizontal position of the player (desktop): 'left', 'right'. Default: 'left'. - **positionPlayerMobile** (string) - Optional - Horizontal position of the player (mobile): 'left', 'right'. Default: 'left'. - **positionBar** (string) - Optional - Horizontal position of the accessibility bar: 'left', 'right'. Default: 'left'. - **offsetTopBar** (string) - Optional - Vertical position of the bar (e.g., '40%', '100px'). Default: '40%'. - **offsetX** (number) - Optional - Horizontal offset of the player in pixels. Default: 60. - **offsetY** (number) - Optional - Vertical offset of the player in pixels. Default: 60. - **size** (number) - Optional - Size of the player in pixels. Default: 280. - **backgroundColorBar** (string) - Optional - Hexadecimal background color for the accessibility bar. Default: '#316181'. - **zIndexBar** (number) - Optional - Z-index stack order for the accessibility bar. - **renderTimeout** (number) - Optional - Render delay in milliseconds. Default: 0. - **mode** (string) - Optional - Operation mode: 'full', 'api'. Default: 'full'. ``` -------------------------------- ### Flutter Basic Implementation Source: https://docs.rybena.com.br/docs/integrations/mobile-apps A complete example of integrating Rybená within a Flutter StatefulWidget using WebViewController. ```dart import 'package:flutter/material.dart'; import 'package:webview_flutter/webview_flutter.dart'; class RybenáIntegration extends StatefulWidget { @override _RybenáIntegrationState createState() => _RybenáIntegrationState(); } class _RybenáIntegrationState extends State { late WebViewController _controller; // URL da WebView da Rybená com seu token de autenticação final String rybenaUrl = 'https://repository.rybena.com.br/webview/index.html?token=SEU-TOKEN-AQUI'; @override void initState() { super.initState(); _controller = WebViewController() ..setJavaScriptMode(JavaScriptMode.unrestricted) ..setNavigationDelegate( NavigationDelegate( onPageFinished: (String url) { // WebView carregada com sucesso }, ), ) ..loadRequest(Uri.parse(rybenaUrl)); } // Função para manipular o tamanho da Rybená Future setSize(int size) async { await _controller.runJavaScript( 'RybenaApi.getInstance().setSize($size);' ); } // Função para abrir o player Future openPlayer() async { await _controller.runJavaScript( 'RybenaApi.getInstance().openPlayer();' ); } // Função para fechar o player Future closePlayer() async { await _controller.runJavaScript( 'RybenaApi.getInstance().closePlayer();' ); } @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar(title: Text('Rybená Integration')), body: Column( children: [ Expanded( child: WebViewWidget(controller: _controller), ), Padding( padding: const EdgeInsets.all(16.0), child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ ElevatedButton( onPressed: () => setSize(300), child: Text('Definir Tamanho'), ), ElevatedButton( onPressed: openPlayer, child: Text('Abrir Player'), ), ElevatedButton( onPressed: closePlayer, child: Text('Fechar Player'), ), ], ), ), ], ), ); } } ``` -------------------------------- ### Instalar Rybená no Wix Source: https://docs.rybena.com.br/docs/integrations/wix Cole este script na seção de Código Personalizado do Wix para aplicar a Rybená a todas as páginas. ```html ``` -------------------------------- ### Exemplo Completo de Customização da Rybená com Barra Customizada Source: https://docs.rybena.com.br/docs/getting-started/customization Este exemplo demonstra a integração completa da Rybená, incluindo a barra de acessibilidade customizada, estilos CSS e o script principal da Rybená. Certifique-se de que o script da Rybená esteja incluído no cabeçalho do seu documento. ```html {/* Rybená Script */} {/* Custom Styles */} {/* Custom Accessibility Bar */}
{/* Your Content */}

Bem-vindo ao Meu Site

Este é um exemplo de site com Rybená customizada.

``` -------------------------------- ### Exemplo: Player Responsivo Source: https://docs.rybena.com.br/docs/api/player-control Ajusta o tamanho e a posição do player com base no tamanho da tela, garantindo uma boa experiência tanto em dispositivos móveis quanto em desktops. Inclui um listener para redimensionamento da janela. ```javascript function adjustPlayerForScreen() { const isMobile = window.innerWidth < 768; if (isMobile) { // Tamanho menor para mobile RybenaApi.getInstance().setSize(0.6); RybenaApi.getInstance().setCoordinates(10, 10); } else { // Tamanho normal para desktop RybenaApi.getInstance().setSize(1.0); RybenaApi.getInstance().setCoordinates(20, 20); } } RybenaApi.getInstance().handleLoaded(() => { RybenaApi.getInstance().openPlayer(); adjustPlayerForScreen(); // Ajusta quando a janela é redimensionada window.addEventListener('resize', adjustPlayerForScreen); }); ``` -------------------------------- ### Instalar Rybená em HTTP no Wix Source: https://docs.rybena.com.br/docs/integrations/wix Use este script se a sua página Wix não utiliza o protocolo HTTPS. Substitua 'https' por 'http'. ```html ``` -------------------------------- ### Exemplo: Player em Modo Transparente Source: https://docs.rybena.com.br/docs/api/player-control Mostra como usar o modo transparente para uma experiência de usuário mais imersiva, combinando com posicionamento central e tradução de texto. ```javascript RybenaApi.getInstance().handleLoaded(() => { // Mostra o player RybenaApi.getInstance().openPlayer(); // Define modo transparente RybenaApi.getInstance().setToTransparentMode(); // Posiciona no centro const centerX = window.innerWidth / 2 - 200; const centerY = window.innerHeight / 2 - 150; RybenaApi.getInstance().setCoordinates(centerX, centerY); // Traduz um texto RybenaApi.getInstance().translate("Bem-vindo!"); }); ``` -------------------------------- ### Integrate Rybená with Vue 3 Source: https://docs.rybena.com.br/docs/api/examples A Vue 3 component setup using the Composition API to manage the Rybená script lifecycle and API interactions. ```typescript ``` -------------------------------- ### Initialize and Configure Rybena API Source: https://docs.rybena.com.br/docs/api/examples This script initializes the Rybena API, sets up event handlers for loading and translation completion, and configures UI elements. It requires the Rybena JavaScript library to be loaded. ```javascript // Elementos DOM const loading = document.getElementById('loading'); const controls = document.getElementById('controls'); const textInput = document.getElementById('textInput'); const status = document.getElementById('status'); const librasBtn = document.getElementById('librasBtn'); const vozBtn = document.getElementById('vozBtn'); const slowBtn = document.getElementById('slowBtn'); const normalBtn = document.getElementById('normalBtn'); const fastBtn = document.getElementById('fastBtn'); const translateBtn = document.getElementById('translateBtn'); const pauseBtn = document.getElementById('pauseBtn'); const playBtn = document.getElementById('playBtn'); const stopBtn = document.getElementById('stopBtn'); let currentMode = 'libras'; let currentSpeed = 1.0; // Aguarda a Rybená carregar RybenaApi.getInstance().handleLoaded(() => { console.log('Rybená carregada!'); // Mostra os controles loading.style.display = 'none'; controls.style.display = 'block'; // Abre o player RybenaApi.getInstance().openPlayer(); RybenaApi.getInstance().switchToLibras(); }); // Configura callback para quando a tradução terminar RybenaApi.getInstance().handleTranslate(() => { console.log('Tradução concluída!'); updateStatus('ready', 'Pronto para traduzir'); updateButtonStates(); }); // Funções de controle function translate() { const text = textInput.value.trim(); if (text) { updateStatus('translating', 'Traduzindo...'); RybenaApi.getInstance().translate(text); updateButtonStates(); } } function pause() { RybenaApi.getInstance().pause(); updateStatus('ready', 'Tradução pausada'); } function play() { RybenaApi.getInstance().play(); updateStatus('translating', 'Traduzindo...'); } function stop() { RybenaApi.getInstance().stop(); updateStatus('ready', 'Tradução parada'); updateButtonStates(); } function setMode(mode) { currentMode = mode; if (mode === 'libras') { RybenaApi.getInstance().switchToLibras(); librasBtn.classList.add('active'); vozBtn.classList.remove('active'); } else { RybenaApi.getInstance().switchToVoz(); vozBtn.classList.add('active'); librasBtn.classList.remove('active'); } } function setSpeed(speed) { currentSpeed = speed; RybenaApi.getInstance().setSpeed(speed); slowBtn.classList.remove('active'); normalBtn.classList.remove('active'); fastBtn.classList.remove('active'); if (speed === 0.75) { slowBtn.classList.add('active'); } else if (speed === 1.0) { normalBtn.classList.add('active'); } else if (speed === 1.5) { fastBtn.classList.add('active'); } } function updateStatus(type, message) { status.className = 'status ' + type; status.textContent = message; } function updateButtonStates() { const isTranslating = RybenaApi.getInstance().isTranslating(); const hasText = textInput.value.trim().length > 0; translateBtn.disabled = !hasText || isTranslating; pauseBtn.disabled = !isTranslating; playBtn.disabled = !isTranslating; stopBtn.disabled = !isTranslating; } // Event listeners translateBtn.addEventListener('click', translate); pauseBtn.addEventListener('click', pause); playBtn.addEventListener('click', play); stopBtn.addEventListener('click', stop); librasBtn.addEventListener('click', () => setMode('libras')); vozBtn.addEventListener('click', () => setMode('voz')); slowBtn.addEventListener('click', () => setSpeed(0.75)); normalBtn.addEventListener('click', () => setSpeed(1.0)); fastBtn.addEventListener('click', () => setSpeed(1.5)); textInput.addEventListener('input', updateButtonStates); ``` -------------------------------- ### Initialize Accessibility Manager and Apply Settings Source: https://docs.rybena.com.br/docs/api/typescript-support Instantiates the AccessibilityManager and demonstrates setting line height, contrast, and retrieving preferences. Ensure the API is loaded before use. ```typescript RybenaApi.getInstance().handleLoaded(() => { const api = RybenaApi.getInstance(); const accessibilityManager = new AccessibilityManager(api); // Ativa altura da linha accessibilityManager.toggleLineHeight(); // Define contraste escuro accessibilityManager.setContrast('dark'); // Obtém preferências atuais const prefs = accessibilityManager.getPreferences(); console.log('Preferências:', prefs); }); ``` -------------------------------- ### Exemplo de Barra de Acessibilidade com Links Source: https://docs.rybena.com.br/docs/getting-started/customization Use links em vez de botões para acionar as funcionalidades de acessibilidade. O atributo 'href' deve ser definido conforme a necessidade da navegação. ```html ``` -------------------------------- ### Exemplo Completo: Tradução Básica Rybená Source: https://docs.rybena.com.br/docs/api/translation-control Demonstra como inicializar a API, abrir o player e traduzir um texto simples. ```javascript RybenaApi.getInstance().handleLoaded(() => { // Mostra o player RybenaApi.getInstance().openPlayer(); // Traduz um texto RybenaApi.getInstance().translate("Bem-vindo à Rybená!"); }); ``` -------------------------------- ### Exemplo Completo de Integração Source: https://docs.rybena.com.br/docs/api/getting-started Exemplo de uma página HTML completa integrando botões de controle com a API Rybená. ```html Rybená API Exemplo

Exemplo de API Rybená

``` -------------------------------- ### Inicialização com Modo API e Idioma Source: https://docs.rybena.com.br/docs/api/language-control Combine o parâmetro 'mode=api' com o parâmetro de idioma para utilizar as funcionalidades programáticas da Rybená. ```html ``` -------------------------------- ### Implementar site multilíngue com seletor Source: https://docs.rybena.com.br/docs/getting-started/internationalization Exemplo completo de estrutura HTML com estilos e script da Rybená para um site multilíngue. ```html Meu Site Multilíngue

Bem-vindo ao Meu Site

Este é um exemplo de site multilíngue com Rybená.

``` -------------------------------- ### Instalar dependência React Native WebView Source: https://docs.rybena.com.br/docs/integrations/mobile-apps Comando para adicionar o pacote necessário ao projeto React Native. ```bash npm install react-native-webview # ou yarn add react-native-webview ``` -------------------------------- ### Controlar Contraste Claro Source: https://docs.rybena.com.br/docs/api/accessibility-features Gerencie o modo de contraste claro. Use `toggleLightContrast` para alternar, `startLightContrast` para ativar e `stopLightContrast` para desativar. ```javascript // Toggle RybenaApi.getInstance().toggleLightContrast() // Ativar RybenaApi.getInstance().startLightContrast() // Desativar RybenaApi.getInstance().stopLightContrast() ``` -------------------------------- ### Instalação Básica da Rybená Source: https://docs.rybena.com.br/docs/getting-started/installation Adicione este script dentro da tag head do seu documento HTML para carregar a Rybená. ```html ``` -------------------------------- ### Implementar Player de Tradução com Controles Source: https://docs.rybena.com.br/docs/api/translation-control Configura os botões da interface para interagir com o player, incluindo tradução, reprodução, alternância de modo e ajuste de velocidade. ```javascript RybenaApi.getInstance().handleLoaded(() => { RybenaApi.getInstance().openPlayer(); // Configura botões document.getElementById('translateBtn').addEventListener('click', () => { const text = document.getElementById('textInput').value; if (text) { RybenaApi.getInstance().translate(text); } }); document.getElementById('pauseBtn').addEventListener('click', () => { RybenaApi.getInstance().pause(); }); document.getElementById('playBtn').addEventListener('click', () => { RybenaApi.getInstance().play(); }); document.getElementById('stopBtn').addEventListener('click', () => { RybenaApi.getInstance().stop(); }); document.getElementById('librasBtn').addEventListener('click', () => { RybenaApi.getInstance().switchToLibras(); }); document.getElementById('vozBtn').addEventListener('click', () => { RybenaApi.getInstance().switchToVoz(); }); // Controle de velocidade document.getElementById('speedSlow').addEventListener('click', () => { RybenaApi.getInstance().setSpeed(0.75); }); document.getElementById('speedNormal').addEventListener('click', () => { RybenaApi.getInstance().setSpeed(1.0); }); document.getElementById('speedFast').addEventListener('click', () => { RybenaApi.getInstance().setSpeed(1.5); }); }); ``` -------------------------------- ### Configure Multiple Callbacks for Translation Events Source: https://docs.rybena.com.br/docs/api/event-handlers Demonstrates setting up several distinct functions to execute when a translation event occurs. This allows for modular handling of different actions upon translation completion. ```javascript RybenaApi.getInstance().handleLoaded(() => { console.log("1. Rybená carregada"); RybenaApi.getInstance().openPlayer(); // Callback 1: Log de tradução RybenaApi.getInstance().handleTranslate(() => { console.log("2. Tradução concluída"); }); // Callback 2: Atualizar interface RybenaApi.getInstance().handleTranslate(() => { document.getElementById('status').textContent = "Pronto"; }); // Callback 3: Traduzir próximo texto RybenaApi.getInstance().handleTranslate(() => { if (hasMoreTexts()) { translateNext(); } }); // Traduz um texto RybenaApi.getInstance().translate("Texto de exemplo"); }); ``` -------------------------------- ### Download do Plugin Rybená Source: https://docs.rybena.com.br/docs/getting-started/pdf-integration Link para baixar o plugin customizado necessário para a integração. ```text https://drive.google.com/file/d/1qJZ8iIe0MBzSYnQz9VV38YRsrjAf8sPq/view?usp=sharing ``` -------------------------------- ### Implementar visualizador de PDF acessível com Rybená Source: https://docs.rybena.com.br/docs/getting-started/pdf-integration Exemplo de estrutura HTML para exibir um PDF acessível através de um iframe, incluindo o script da Rybená e estilos básicos. ```html PDF com Acessibilidade Rybená

Manual do Usuário

Este documento está acessível com Rybená. Selecione qualquer texto para tradução em LIBRAS ou voz.

``` -------------------------------- ### Inicialização da API com Idioma Específico Source: https://docs.rybena.com.br/docs/api/language-control Adicione o parâmetro 'lang' à URL do script para definir o idioma de inicialização da Rybená. ```html ``` ```html ``` ```html ``` -------------------------------- ### Integrate Rybená with Vanilla JavaScript Source: https://docs.rybena.com.br/docs/api/examples A basic HTML structure and CSS for implementing the Rybená service without a framework. ```html Rybená - Vanilla JavaScript

Rybená - Vanilla JavaScript