Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
128 views
in Technique[技术] by (71.8m points)

javascript - Cordova Music Controls Plugin, how to make it work?

@Rivers with this code:

<div onclick="play();" id="play" class="play">
       PLAY
</div>

<div onclick="pause()" id="stop" class="disable stop">
       STOP
</div>

<div>
      <audio id="player" controls>
              <source src="https://9230.brasilstream.com.br/stream" type="audio/aac">
      </audio>
</div>

<script src="cordova.js"></script>
<script src="js/jquery351min.js"></script>
<script src="js/bootstrap.bundle.min.js"></script>

<script type="text/javascript">
var audioplayer = document.getElementById("player");

function play(){
       audioplayer.play();
}
function pause(){
        audioplayer.pause();
}

</script>

I have this: IMG LINK

And is working just fine...

But i need also this:CONTROL PLAYER ON THE NOTIFICATION AREA

That should work with this code:

LINK plugin: https://github.com/ghenry22/cordova-plugin-music-controls2

audioplayer.MusicControls.create({
    track       : 'Time is Running Out',        // optional, default : ''
    artist      : 'Muse',                       // optional, default : ''
    album       : 'Absolution',     // optional, default: ''
    cover       : 'albums/absolution.jpg',      // optional, default : nothing
    // cover can be a local path (use fullpath 'file:///storage/emulated/...', or only 'my_image.jpg' if my_image.jpg is in the www folder of your app)
    //           or a remote url ('http://...', 'https://...', 'ftp://...')
    isPlaying   : true,                         // optional, default : true
    dismissable : true,                         // optional, default : false

    // hide previous/next/close buttons:
    hasPrev   : false,      // show previous button, optional, default: true
    hasNext   : false,      // show next button, optional, default: true
    hasClose  : true,       // show close button, optional, default: false

    // iOS only, optional

    duration : 60, // optional, default: 0
    elapsed : 10, // optional, default: 0
    hasSkipForward : true, //optional, default: false. true value overrides hasNext.
    hasSkipBackward : true, //optional, default: false. true value overrides hasPrev.
    skipForwardInterval : 15, //optional. default: 0.
    skipBackwardInterval : 15, //optional. default: 0.
    hasScrubbing : false, //optional. default to false. Enable scrubbing from control center progress bar 

    // Android only, optional

    // text displayed in the status bar when the notification (and the ticker) are updated
    ticker    : 'RADIO GAZETA"',
    //All icons default to their built-in android equivalents
    //The supplied drawable name, e.g. 'media_play', is the name of a drawable found under android/res/drawable* folders
    playIcon: 'media_play',
    pauseIcon: 'media_pause',
    prevIcon: 'media_prev',
    //nextIcon: 'media_next',
   //closeIcon: 'media_close',
    notificationIcon: 'notification'
}, onSuccess, onError);

But it doesn't work and I don't know if I'm doing something wrong, because I'm new to the area and there is no example in the documentation on git.

question from:https://stackoverflow.com/questions/65886662/cordova-music-controls-plugin-how-to-make-it-work

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...