简体   繁体   English

更改 javascript 音频播放器的用户代理

[英]Change user-agent of javascript audio player

I use the following code to play an audio stream on my site and was wondering if how I could change the user-agent so that it appears in the streaming server logs as something other than 'Mozilla 5' for example.我使用以下代码在我的网站上播放音频 stream 并想知道是否可以更改用户代理,以便它在流服务器日志中显示为“Mozilla 5”以外的其他内容。 Ideally I want to set it to a custom value so that I can identify it in the logs.理想情况下,我想将其设置为自定义值,以便我可以在日志中识别它。

I'm assuming that I may need something more custom (a custom developed player) to do this, or would it always display this as ultimately the request is coming from a browser?我假设我可能需要更多自定义的东西(自定义开发的播放器)来执行此操作,或者它是否总是显示这个请求最终来自浏览器?

<script>
    var audio = new Audio("<?php echo $player_stream; ?>");
    $('#play-pause-button, #play-pause-button-small').on("click", function() {
    if ($(this).hasClass('fa-play')) {
        $(this).removeClass('fa-play');
        $(this).addClass('fa-pause');
        audio.play();
        } else {
        $(this).removeClass('fa-pause');
        $(this).addClass('fa-play');
        audio.pause();
        }
    });

    audio.onended = function() {
    $("#play-pause-button, #play-pause-button-small").removeClass('fa-pause');
    $("#play-pause-button, #play-pause-button-small").addClass('fa-play');
    };

    $(".btn-effect").click(function() {
        $("." + $(this).attr('id')).css("display", "block")
        });
</script>

You could try navigator.userAgent .您可以尝试navigator.userAgent
EXAMPLE:例子:

var usr = navigator.userAgent;

and send usr to the server.并将usr发送到服务器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更改音频标签的User-Agent - Change User-Agent of audio tag 如何将浏览器用户代理 Header 更改为 javaScript? - How to change browser User-Agent Header with javaScript? 基于User-Agent提供JavaScript - Serving JavaScript based on User-Agent 如何在javascript中检索用户代理值(未定义代理)? - How to retrieve user-agent value in javascript (Agent is not defined)? 在具有IE = EDGE内容(Javascript,setRequestHeader)的HTA应用程序中,User-Agent不变 - User-Agent doesn't change in HTA application with IE=EDGE content (Javascript, setRequestHeader) Javascript user-agent(ajax)与请求网站时发送的用户代理不同 - Javascript user-agent (ajax) different to sent user-agent when requesting website 将casperjs的默认浏览器更改为chrome(更改用户代理字符串) - Change the default browser of casperjs to chrome (Change the user-agent string) 如何更改请求标头(用户代理)中的客户端信息? - How to change the client informations in the request header (User-Agent)? 有什么方法可以更改 Apps 脚本的 User-Agent 吗? - Is there any way to change User-Agent of Apps script? 如何使用 JavaScript 在用户代理影子根中获取元素? - How to get element in user-agent shadow root with JavaScript?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM