I am working on a project, a web site for playing movies.
I'm having trouble setting the language of the video, in case some films are dual audio.
How can I do this procedure? I want to leave the video language in PT-BR.
I made the PHP script below, but it doesn't work, thank you to anyone who can help, thanks.
<script type="text/javascript">
var streamsrc = "<?php echo IP; ?>/<?php echo $tipo; ?>/<?php echo $user; ?>/<?php echo $pwd; ?>/<?php echo $id; ?>.<?php echo $exts; ?>";
var playerobj = window.playerobj = videojs("livevideo", {sources: {type: "video/mp4", src: streamsrc}, controls: true, autoplay: true, loop: false, language: "pt-br", languages: {pt-br: {LIVE: "AO VIVO", Fullscreen: "Tela inteira", Pause: "Pausar", Play: "Reproduzir", Mute: "Mudo", Unmute: "Ativar som"}}, notSupportedMessage: "Ops, algo saiu errado.", preload: "none", muted: false, controlBar: { fullscreenToggle: false, volumePanel: false }, plugins: { airplayButton: {} }});
playerobj.on('ended', function() { go('filmes.php?sessao=<?php echo $_GET['sessao']; ?>&id=<?php echo $idcategoria; ?>'); });
</script>
<?php } ?>
My Answer:
To change the video language in PHP, you can modify the language attribute in the videojs function. In your code, you have already set the language to "pt-br", so the video player should display the controls in Portuguese (Brazil).
If you want to change the language dynamically based on user preferences or other conditions, you can use PHP to generate the language attribute value. For example, you can store the user's preferred language in a variable and then use that variable to set the language attribute in the videojs function.
Here's an example of how you can dynamically change the video language in PHP:
php
// Get the user's preferred language from a session variable or database
$userLanguage = "pt-br"; // Example: user's preferred language is Portuguese (Brazil)
// Generate the language attribute value based on the user's preferred language
$languageAttribute = "language: '" . $userLanguage . "',";
// Output the language attribute in the videojs function
echo "";
?>
In this code snippet, the $userLanguage variable stores the user's preferred language (in this case, "pt-br"). The $languageAttribute variable is then generated based on the user's preferred language and included in the videojs function to set the video language dynamically.
Rate this post
3 of 5 based on 7017 votesComments