completed Audio Pro - Embed Audio Playlist to External Site

Dazed
Dazed
@dazed
4 years ago
1,022 posts
Someone was looking for this and I used to have code on ProJam using Nate's Flash players so a user could embed all audio. I thought I could do this with a playlist but maybe not externally? I thought this was built in but maybe not.

The only other thing I can thing of doing is creating a separate embed page and forcing an iframe? I hate iframes lol.
updated by @dazed: 05/05/20 08:44:03AM
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Hey Michael. Not really hehe. I get 50 players instead of one player with all tunes.

I changed it back to one for now but no song info. What I want is a player with all songs by profile id that can be embeded on a public html page.

https://mixposure.com/test

test.tpl:
{jrCore_list module="jrAudio" order_by="_item_id desc" limit="50" template="standalone_player.tpl" profile_id="166116"}

standalone_player.tpl
{if isset($_items)}
{foreach $_items as $item}
{jrCore_media_player type="jrAudio_player_dark" module="jrAudio" field="audio_file" item=$item}
{/foreach}
{/if}

updated by @dazed: 01/18/20 06:56:05PM
nate
@nate
4 years ago
911 posts
Yeah the way you've written that it's going to create a player for every item. Instead of a jrCore list try this

{jrCore_media_player
        type="jrAudio_player_dark"
        module="jrAudio"
        field="audio_file"
        search1="_profile_id = 166116"
        order_by="audio_file_track numerical_asc"
        limit="50" 
        autoplay=false}
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Hey Nate! Same result. I am just calling test.tpl

{jrCore_media_player
        type="jrAudio_player_dark"
        module="jrAudio"
        field="audio_file"
        search1="_profile_id = 166116"
        order_by="audio_file_track numerical_asc"
        limit="50" 
        autoplay=false}
michael
@michael
4 years ago
7,692 posts
That works for me. I wrapped it in a the header and footer:

{jrCore_include template="header.tpl"}

{jrCore_media_player
        type="jrAudio_player_dark"
        module="jrAudio"
        field="audio_file"
        search1="_profile_id = 1"
        order_by="audio_file_track numerical_asc"
        limit="50"
        autoplay=false}

{jrCore_include template="footer.tpl"}
result.jpg
result.jpg  •  405KB

Dazed
Dazed
@dazed
4 years ago
1,022 posts
Hey Michael. It works to a point. I just updated test.tpl but it shows up as Admin (like yours) but the profile id I am using is a different user. So something went south. This will also need to be able to be embeded on another site so they probably do not want the header and footer heh.
michael
@michael
4 years ago
7,692 posts
test.tpl is not a good name, use trial.tpl or junk.tpl or something. I think theres something somewhere that checks for the /test/ in the domain part. Just had weird results with it in the past.

You'll need to bring in the meta.tpl file so for now just wrap it in the header and footer so you know all the needed javascript for the player is there, then start removing the graphical stuff once you've got it working.

Check that the profile_id you're using
* does have audio files
* is not set to private

later, once you have it working with the profile_id hard coded you can change it to use a URL parameter, eg:
yoursite.com/trial/1

Then use {debug} to find out which $_post variable the '1' part of the url comes out on and put that into your player so you can get any profile you want by changing the URL.
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Thanks Michael.

renamed - https://www.mixposure.com/aaa
resolved the profile id issue. (my bad on cut and paste)
No Song Names on the player.
nate
@nate
4 years ago
911 posts
Make sure the js is there. You'll want to make a special header and footer with very little html. You need the js. perhaps

<head>
  -- include meta template
</head>
<body>
  --player here
</body>

updated by @nate: 01/21/20 07:48:20AM
michael
@michael
4 years ago
7,692 posts
I saw the same thing on my super-quick testing setup and didn't think much of it, try a different player:
jrBeatSlinger_audio_player
jrFollowMe2_audio_player
jrISkin_audio_player
blue_monday (or maybe jrAudio_blue_monday not sure of the syntax)
nate
@nate
4 years ago
911 posts
Try

jrAudioPro_playlist_player.tpl
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Thanks guys. No luck. I did not think this would be this difficult lol.

I added meta.tpl and no change.
Other players yielded the same results
Playlist is an option but I have tried that also and no go.

https://www.mixposure.com/aaa

{jrCore_include template="header.tpl"}

{jrCore_media_player 
type="jrPlaylist_player_dark" 
module="jrPlaylist" 
item="1" 
limit="100" 
// also tried - search1="_profile_id = 166116" because I believe the playlist is tied to the profile
autoplay=false}
nate
@nate
4 years ago
911 posts
No, like this.

{jrCore_media_player
        type="jrAudioPro_playlist_player"
        module="jrAudio"
        field="audio_file"
        search1="_profile_id = 1"
        order_by="audio_file_track numerical_asc"
        limit="50"
        autoplay=false}
nate
@nate
4 years ago
911 posts
The problem I saw before was your players JS did not include track titles.
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Hey Nate - Correct. I updated the change you mentioned above which displays a single player - no tracks.
nate
@nate
4 years ago
911 posts
Give me a log in.
nate
@nate
4 years ago
911 posts
You know what, scratch the log in. I'm gonna work it out on my test site and post the code. That way others can see it and use it.
nate
@nate
4 years ago
911 posts
I've been trying to get this to work and I can't believe I'm having this much trouble. I'll continue. I just didn't want you to think I quit on ya.
nate
@nate
4 years ago
911 posts
I finally have a player showing titles.

https://test.theflirtapp.com/audio_embed/profile_id=2

Step 1. Change the jrAudioPro_playlist_player.tpl to this code.
{jrCore_module_url module=$params.module assign="murl"}
<script type="text/javascript">
    $(document).ready(function() {

        var jp_volume = 0.8;
        var volumeCookie = jrReadCookie('jrAudioPro2_audio_volume');
        if(volumeCookie && volumeCookie.length > 0) {
            jp_volume = volumeCookie;
        }

        var tw = $('#jp_container_{$uniqid}').width();
        var th = Math.round(tw / 1.778);
        $('#jp_container_{$uniqid} .jp-gui').height(th-30);

        new jPlayerPlaylist( {
            jPlayer: "#jquery_jplayer_{$uniqid}",
            cssSelectorAncestor: "#jp_container_{$uniqid}"
        } , [
            {if isset($media) && is_array($media)}
            {foreach $media as $item}
            {

                {$album_url = "`$jamroom_url`/`$item._item.profile_url`/`$item.module_url`/albums/`$item._item.audio_album_url`"}
                {$field = 'audio_file'}
                {$image = 'audio_image'}
                title: "{$item._item.audio_title|truncate:55}",
                artist: "{$item.artist|truncate:55}",
                item_id: "{$item.item_id}",
                poster: "{$item.poster}?crop=auto",

                {if isset($item._item.video_title)}
                {$album_url = "`$jamroom_url`/`$item._item.profile_url`/`$item.module_url`/albums/`$item._item.video_album_url`"}
                {$field = 'field_file'}
                {$image = 'video_image'}
                title: "{$item._item.video_title|truncate:55}",
                artist: "{$item.artist|truncate:55}",
                item_id: "{$item.item_id}",
                poster: "{$item.poster}?crop=auto",
                {/if}



        {foreach $item.formats as $format => $url}
        {$format}: "{$url}",
        {/foreach}
    } ,
    {/foreach}
    {/if}
    ] , {
        play : function() {
            $("#jquery_jplayer_{$uniqid} .jp-gui").removeClass('start');
        },
        error: function(res) { jrCore_stream_url_error(res); },
        playlistOptions: {
            autoPlay: {$autoplay},
            displayTime: 'fast'
        },
        swfPath: "{$jamroom_url}/modules/jrCore/contrib/jplayer",
                supplied: "{$formats}",
                solution: "{$solution}",
                volume: jp_volume,
                preload: 'none',
                wmode: 'opaque',
                size: { width: "100", height: "100px" },
                smoothPlayBar: true,
                keyEnabled: true,
                remainingDuration: true,
                toggleDuration: true

    });

    var holder = $('#jp_container_{$uniqid} .jp-controls-holder');
    var gui = $('#jp_container_{$uniqid}  .jp-gui');
    var title = $('#jp_container_{$uniqid}  .jp-title');

        $('#jp_container_{$uniqid}').bind($.jPlayer.event.volumechange, function(event){
            jp_volume = event.jPlayer.options.volume;
            if($("#jp_container_{$uniqid}").hasClass('jp-state-muted')) {
                jp_volume = 0
            }
            jrSetCookie('jrAudioPro2_audio_volume', jp_volume, 31);
        });

})
</script>

<div class="jrAudioPro2_audio playlist" onclick="event.cancelBubble = true; if(event.stopPropagation) event.stopPropagation();">
    <div id="jp_container_{$uniqid}" class="jp-audio">
        <div class="jp-type-playlist">
            <div class="video_container">
                <div id="jquery_jplayer_{$uniqid}" class="jp-jplayer"></div>
                <div class="jp-gui start">
                    <div class="jp-title">
                        <ul>
                            <li></li>
                        </ul>
                    </div>
                    <div class="jp-interface">
                        <div class="jp-controls-holder">
                            <ul class="jp-controls" id="play-pause">
                                <li><a class="jp-play" tabindex="{jrCore_next_tabindex}" title="{jrCore_lang module="jrVideo" id="1" default="play"}"></a></li>
                                <li><a class="jp-pause" tabindex="{jrCore_next_tabindex}" title="{jrCore_lang module="jrVideo" id="2" default="pause"}"></a></li>
                            </ul>
                            <div class="jp-progress-holder">
                                <div class="jp-progress">
                                    <div class="jp-seek-bar">
                                        <div class="jp-play-bar"></div>
                                    </div>
                                </div>
                            </div>
                            <div class="jp-duration"></div>
                            <ul class="jp-controls" id="mute-unmute">
                                <li><a class="jp-mute" tabindex="{jrCore_next_tabindex}" title="{jrCore_lang module="jrVideo" id="4" default="mute"}"></a></li>
                                <li><a class="jp-unmute" tabindex="{jrCore_next_tabindex}" title="{jrCore_lang module="jrVideo" id="5" default="unmute"}"></a></li>
                            </ul>
                            <div class="jp-volume-bar" style="display: none;">
                                <div class="jp-volume-bar-value"></div>
                            </div>
                            <ul class="jp-toggles">
                                <li><a class="jp-full-screen" tabindex="{jrCore_next_tabindex}" title="{jrCore_lang module="jrVideo" id="55" default="full screen"}"></a></li>
                                <li><a class="jp-restore-screen" tabindex="{jrCore_next_tabindex}" title="{jrCore_lang module="jrVideo" id="56" default="restore screen"}"></a></li>
                            </ul>
                        </div>
                    </div>
                </div>
            </div>
            <div class="jp-playlist" style="display: none;">
                <ul>
                    <li></li>
                </ul>
            </div>
        </div>
    </div>
</div>

Step 2. create a template audio_embed.tpl

{jrCore_include template="header_embed.tpl"}

{jrCore_media_player
type="jrAudioPro2_playlist_player"
module="jrAudio"
field="audio_file"
search1="_profile_id = `$_post.profile_id`"
order_by="audio_file_track numerical_asc"
limit="50"
autoplay=false}

{jrCore_include template="footer_embed.tpl"}

Step 3. Create header_embed.tpl and footer_embed.tpl

header_embed.tpl
{jrCore_include template="meta.tpl"}

footer_embed.tpl
{if isset($css_footer_href)}
    {foreach from=$css_footer_href item="_css"}
        <link rel="stylesheet" href="{$_css.source}" media="{$_css.media|default:"screen"}"/>
    {/foreach}
{/if}
{if isset($javascript_footer_href)}
    {foreach from=$javascript_footer_href item="_js"}
        <script type="{$_js.type|default:"text/javascript"}" src="{$_js.source}"></script>
    {/foreach}
{/if}
{if isset($javascript_footer_function)}
    <script type="text/javascript">
        {$javascript_footer_function}
    </script>
{/if}

</body>
</html>

updated by @nate: 01/27/20 01:52:44PM
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Awesome thanks Nate. I will see if I can get this added tomorrow.
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Thanks Nate. Unfortunately this did not work for me but the reason behind it is probably because I have a customized theme. My theme did not have jrAudio_playlist_player.tpl in it. I thought it was possibly in the audio module but I found in the the jrAudio release files. Sooooo that would be my issue since I am not running the current version. I will have to take some time and see if I can make this a bit more current.
nate
@nate
4 years ago
911 posts
Give me your log in. We just need to add the player in your include.php
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Thanks Nate. I created a ticket with the info
nate
@nate
4 years ago
911 posts
okay
nate
@nate
4 years ago
911 posts
https://www.mixposure.com/audio_embed/profile_id=166116

One thing I did notice is the chat room is showing. I'm going to see if I can hide or remove it.
Dazed
Dazed
@dazed
4 years ago
1,022 posts
Awesome!! Thanks Nate!! I appreciate the help ;)
nate
@nate
4 years ago
911 posts
You're welcome. Marking this completed. You can still respond, if you need further assistance.