[英]Change user-agent of javascript audio player
我使用以下代碼在我的網站上播放音頻 stream 並想知道是否可以更改用戶代理,以便它在流服務器日志中顯示為“Mozilla 5”以外的其他內容。 理想情況下,我想將其設置為自定義值,以便我可以在日志中識別它。
我假設我可能需要更多自定義的東西(自定義開發的播放器)來執行此操作,或者它是否總是顯示這個請求最終來自瀏覽器?
<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>
您可以嘗試navigator.userAgent 。
例子:
var usr = navigator.userAgent;
並將usr
發送到服務器。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.