# Play, Pause, and Seek
# Play, Pause, and Seek audio with JavaScript
It's possible to use JavaScript to control playback of the Backtracks Player.
<html>
<div data-bt-embed="https://player.backtracks.fm/backtracks/backtracks/m/player-example"
data-bt-theme="dark"
data-bt-show-comments="false"
data-bt-show-art-cover="true"
data-bt-preview="false">
</div>
<div class="player-controls">
<button id="btn-play">PLAY</button>
<button id="btn-pause">PAUSE</button>
<button id="btn-seek">SEEK to 30s</button>
<button id="btn-seek-back">SEEK ← 15s</button>
<button id="btn-seek-ahead">SEEK → 30s</button>
</div>
</html>
<script>
(function(p,l,a,y,s){if(p[a])return
if(p[y])return p[y]();s=l.createElement('script')
l.head.appendChild((s.async=p[a]=true,
s.src='https://player.backtracks.fm/embedder.js',
s))}(window,document,'__btL','__btR'));
var player = null;
window.onBacktracksLoad = function(BT) {
player = BT.getAll()[0];
document.getElementById('btn-play').addEventListener('click', function() {
// method 1: player.play() method
player.play();
// method 2: set audio paused property to false
// player.audio({'paused': false})
});
document.getElementById('btn-pause').addEventListener('click', function() {
// method 1: player.pause() method
player.pause();
// method 2: set audio paused property to false
// player.audio({'paused': false})
});
document.getElementById('btn-seek').addEventListener('click', function() {
// method 1: set audio seekTo property to position in number of seconds
player.audio({ seekTo: 30.0 })
// method 2: set audio currentTime property to position in number of seconds
// player.audio({currentTime: 17.29})
});
document.getElementById('btn-seek-back').addEventListener('click', function() {
// method 1: seek backwards by a number of seconds
player.audio({ relativeSeekTo: -15.0 })
});
document.getElementById('btn-seek-ahead').addEventListener('click', function() {
// method 1: seek forward by a number of seconds
player.audio({ relativeSeekTo: 30.0 })
});
}
</script>
<style>
.player-controls {
margin-top:1em;
}
.player-controls button {
font-size: 125%;
border: 0;
background-color: #000;
border-radius: 3px;
color: #2AB;
font-weight: 500;
}
</style>