• Resolved cogdog

    (@cogdog)


    This is a very useful theme for a site I am making to manage just audio post-formats. When there are more than one posts of this format, on the home page and all archive views, the nicely formatted jQuery loaded media player only shows for the first post, the remaining have the standard audio player.

    I noticed in content-audio.php the player is loaded with

    <audio controls="controls" id="audio-player">

    Since the jQuery looks for IDs only, it will only affect the first one:

    // Add custom audio player
    	$('#audio-player').mediaelementplayer({
    	    alwaysShowControls: true,
    	    features: ['playpause','progress','volume'],
    	    audioVolume: 'horizontal',
    	    audioWidth: 872,
    	    audioHeight: 100
    	});

    To fid this, my child theme has its own content-audio.php with

    <audio controls="controls" class="audio-player">

    and the extra JS I am enqueing has

    // Add custom audio player
    	$('.audio-player').mediaelementplayer({
    	    alwaysShowControls: true,
    	    features: ['playpause','progress','volume'],
    	    audioVolume: 'horizontal',
    	    audioWidth: 872,
    	    audioHeight: 100
    	});

    And it seems to be working as I expect.

    This was just a quick test but it would affect any site using more than one audio post-format type post.

    This, like your others, are really elegant themes, and I like building sites from them because they are not bloated.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi!
    Thank you so much for this. I edited the /baskervile/js/global.js to edit the code

    Thank you ??

    Thread Starter cogdog

    (@cogdog)

    You are welcome; you have to also edit content-audio.php and single.php (I used c child theme, so I make copies and edit them) so the audio tag uses a class rather than an id (I did not write that very clearly above).

    Theme Author Anders Norén

    (@anlino)

    Hi cogdog,

    Thanks for taking the time to post this solution; it was a stupid oversight on my part. I’ll add the fix in the next update to Baskerville.

    — Anders

    Hey Anders

    I was just about to report this bug:
    Image
    But i see you will already take care of this soon…

    greetings Matthijs

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Audio Player Needs to be Class Not ID’ is closed to new replies.