How to detect whether a headphone is inserted or removed in JavaScript?

前端 未结 2 1346
别那么骄傲
别那么骄傲 2021-01-01 03:05

Is there any event in JavaScript, I can listen to in browser, through which we can know whether headphones are inserted or removed?

I assume if we are able to iterat

2条回答
  •  清歌不尽
    2021-01-01 03:14

    I am using phone-gap plugin for the same

    HTML:

    JS:

    $scope.checkHeadphone = function () {
            window.plugins.headsetdetection.detect(function (detected) {
                alert("Headphone " + detected)
            })
        }
    

提交回复
热议问题