[英]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.