function koplo_custom_player_display( $player_id ) {
$sampler_data = carbon_get_post_meta( $player_id, 'koplo_sample_files_new', 'complex' );
if ( $sampler_data ) {
?>
<div id="koplo-sample-player-<?php echo esc_attr( $player_id ); ?>" class="aplayer" style="margin-top:30px"></div>
<script type="text/javascript">
var koplo = new APlayer({
element: document.getElementById('koplo-sample-player-<?php echo esc_attr( $player_id ); ?>'),
narrow: false,
autoplay: false,
showlrc: false,
theme: '#e6d0b2',
<?php
$counting = count( $sampler_data );
$counter = 1;
echo ( $counting > 1 ) ? 'music:[' : '';
foreach ( $sampler_data as $key => $file ) : ?>
<?php if ( 1 == $counting ): ?>
music: {
title: '<?php echo esc_attr( $file['title'] ); ?>',
url: '<?php echo wp_get_attachment_url( $file['file'] ); ?>',
author: '<?php echo esc_attr( $file['artist'] ); ?>',
pic: '<?php echo esc_url( $file['cover'] ); ?>',
}
<?php else : ?>
{
title: '<?php echo esc_attr( $file['title'] ); ?>',
url: '<?php echo wp_get_attachment_url( $file['file'] ); ?>',
author: '<?php echo esc_attr( $file['artist'] ); ?>',
pic: '<?php echo esc_url( $file['cover'] ); ?>',
},
<?php endif; ?>
<?php $counter++; endforeach; ?>
<?php echo ( $counting > 1 ) ? ']' : ''; ?>
});
</script>
<style type="text/css">
.aplayer-list ol li {
margin-right: 0 !important;
}
</style>
<?php
}
}