Okay
  Public Ticket #3570688
Updating the Playlist title, possibly dynamically
Closed

Comments

  • Justin Sainton started the conversation

    Trying to update the title of the playlist playing when playing other files besides the default one. A video should be instructive. Note, the URL is behind a password, ilovenews.

    Video

    Thanks!


  •  1,114
    Max replied

    Hi,

    id like to see how you implement the listen button ? is that through a shortcode? If so, what is the shortcode you are using ?


    Thanks,


    Max from the Sonaar.io Crew

  • Justin Sainton replied

    it is a bit of a custom implementation, but essentially just a gutenberg block.

    add_action( 'newspack_theme_entry_meta', function () {

        if ( ! has_block( 'core/audio' ) ) {
            return;
        }

        $block = '';
        $post = get_post()->post_content;

        $first_block = parse_blocks( $post )[0];

        $isFirstBlockAudioPlayer = $first_block['blockName'] === 'core/audio';

        if ( $isFirstBlockAudioPlayer ) {
            $audio_url =  wp_get_attachment_url( $first_block['attrs']['id'] );
            $block .= do_blocks( '<!-- wp:sonaar/sonaar-block {"player_layout":"skin_button","show_volume_bt":"false","show_speed_bt":"false","show_shuffle_bt":"false","show_tracks_count":"false","show_meta_duration":"false","show_publish_date":"false","show_skip_bt":"false","playlist_show_playlist":false,"playlist_show_album_market":false,"playlist_hide_artwork":true,"notrackskip":true,"button_align":"flex-start","hide_player_subheading":true,"audio_player_play_text_color":"#000000","audio_player_play_text_color_hover":"#ffffff","hide_player_title":true,"player_inline":true,"soundwave_show":true,"use_play_label":true,"audio_player_controls_color":"#ffffff","audio_player_controls_color_hover":"#000000","play_text":"Listen","shortcode_parameters":"feed=\u0022' . esc_url( $audio_url )  . '\u0022","play_hover_border_color":"#e86a54","play_border_style":"solid","play_border_width":1} /-->' );
        }

        echo $block;
    } );


  •  1,114
    Max replied

    According to the code provided, it seems you are setting the feed attribute which is fine. You must also set the feed_title attribute to set the track title.

    See our shortcode page to find out all the parameters: https://sonaar.io/docs/add-audio-player-with-shortcode/

    Thanks,


    Max from the Sonaar.io Crew