New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds Custom Error Message Option #187

wants to merge 1 commit into
base: master


None yet
3 participants

MPierre9 commented Jan 25, 2018

Addresses issue #128 and adds the option for custom error messages.


Simply add the error property to the APlayer object and add your custom error message like so:
const ap1 = new APlayer({
element: document.getElementById('player1'),
narrow: false,
autoplay: true,
showlrc: false,
mutex: true,
theme: '#e6d0b2',
preload: 'metadata',
mode: 'circulation',
error: "Error: Song could not load", <=====
music: {
title: 'Preparation',
author: 'Hans Zimmer/Richard Harvey',
url: '',
pic: ''


aplayer error


This comment has been minimized.


MPierre9 commented Feb 1, 2018

@DIYgod does this PR need changes or is it good for merge?

@@ -558,7 +560,7 @@ class APlayer {
// audio download error: an error occurs'error', () => {
this.element.getElementsByClassName('aplayer-author')[0].innerHTML = ` - Error happens ╥﹏╥`;
this.element.getElementsByClassName('aplayer-author')[0].innerHTML = ` - ` + this.option.error;

This comment has been minimized.


micooz Feb 2, 2018


Maybe need to prevent XSS attack here?


This comment has been minimized.


DIYgod commented Feb 2, 2018

I don't want this option, maybe expose an error event to user is a better way, usage is like this:

ap.on('error', function () {
    ap.notice('Error message');

@DIYgod DIYgod closed this Feb 3, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment