我在控制台中收到此错误
SyntaxError: Unexpected token '(' ... line 49
这是有问题的行:
trackEnded: function() {
这是整个代码,我只是不明白为什么会出现该错误?
// Initialize audio js
$(document).ready(function($) {
// Setup the player to autoplay the next track
trackEnded: function() {
var next = $('.main article.playing').next();
if (!next.length) next = $('.main article').first();
next.addClass('playing').siblings().removeClass('playing');
audio.load($('.article-play', next).attr('data-src'));
audio.play();
$('.article-play', next).removeAttr('data-playa').attr("data-pausea", '5');
var nextPlay = $('.article-play', next);
$('.article-play').not(nextPlay).removeAttr('data-pausea').attr("data-playa", '4');
}
//Synchronize Main player with articles
$(".audiojs .play-pause").click(function() {
var element = $('.playing .article-play')
var play = element.attr('data-playa')
var pause = element.attr('data-pausea')
if (play == '4') {
element.removeAttr('data-playa').attr("data-pausea", '5');
} else if (pause == '5') {
element.removeAttr('data-pausea').attr("data-playa", '4');
}
})
// Load in a track on click
$('.article-play').click(function(e) {
e.preventDefault();
if ($(this).closest('article').hasClass('playing')) {
var play = $(this).attr('data-playa')
var pause = $(this).attr('data-pausea')
if (play == '4') {
$(this).removeAttr('data-playa').attr("data-pausea", '5');
$('.article-play').not($(this)).removeAttr('data-pausea').attr("data-playa", '4');
audio.play();
} else if (pause == '5') {
$(this).removeAttr('data-pausea').attr("data-playa", '4');
audio.pause();
}
} else {
$(this).closest('article').addClass('playing').siblings().removeClass('playing');
audio.load($(this).attr('data-src'));
audio.play();
$(this).removeAttr('data-playa').attr("data-pausea", '5');
$('.article-play').not($(this)).removeAttr('data-pausea').attr("data-playa", '4');
}
});
// Keyboard shortcuts
$(document).keydown(function(e) {
var unicode = e.charCode ? e.charCode : e.keyCode;
// right arrow
if (unicode == 39) {
var next = $('.main article.playing').next();
if (!next.length) next = $('.main article').first();
next.find('.article-play').click();
// back arrow
} else if (unicode == 37) {
var prev = $('.main article.playing').prev();
if (!prev.length) prev = $('.main article').last();
prev.find('.article-play').click();
// spacebar
} else if (unicode == 32 && document.activeElement.nodeName !== 'INPUT') {
audio.playPause();
var element = $('.playing .article-play')
var play = element.attr('data-playa')
var pause = element.attr('data-pausea')
if (play == '4') {
element.removeAttr('data-playa').attr("data-pausea", '5');
} else if (pause == '5') {
element.removeAttr('data-pausea').attr("data-playa", '4');
}
}
});
});