Okay
  Public Ticket #2706110
Replacing Post Links with Play Function
Closed

Comments

  • Carson started the conversation

    Hi Sonaar team,

    I have been able to play around with the pro version of the plugin and I was wondering if you have ever touched on the ability to do the following.

    I have lists of playlists setup using the gutenberg post layout.
    I want to be able to replace these links that would normally go to the following playlist page to be able to start playing the selected playlist in the sticky player.

    Is this possible at all?

    I understand that this can call playlists:

    IRON.sonaar.player.setPlayerAndPlay({ id:"1218"})

    But is there already a plugin or something setup that can list out my playlists?

    I will have a look tonight.

    Cheers,
    Carson.


  • Carson replied

    I have been able to do the following: 

    jQuery(document).ready(function($){
       $(".rhr_tracks_slider a").removeAttr("href");
       $(".rhr_tracks_slider a").attr('onclick', "IRON.sonaar.player.setPlayerAndPlay({ id:'307'});");
    });

    This will remove all links from the slider and replace it with the play function.
    All I need now it a way to find out the id for every post item. This will be very hard I think.

  • Carson replied

    Okay so I got it working:


    jQuery(document).ready(function($){
        $('.rhr_tracks_slider a').each(function() {
            var rhr_page_name = $(this).attr('href');
            var result= rhr_page_name.split('/');
            var Param = result[result.length-2];
            $(this).removeAttr("href");
            $(this).attr('onclick', "IRON.sonaar.player.setPlayerAndPlay({ id:'"+Param+"'});");
        });
    });


    The only problem here is that I have to make the slug of the albums the actual post id.
    I wonder if there is a way to pull post ids from a simple link.

    I already tried using the post-name as the id but that didn't work.


  • Carson replied

    Hi, 

    I hope you're able to follow me here in this thread as I have been working on this.

    So I just saw a thread and saw some information about using woocommerce.
    Now I am not looking at turning my site into a store. 


    Can you please tell me if can use the function I have created or if I should be using woocommerce.

    As for what I want my site to do. I just want it to be a library with out going links to bandcamp and youtube.
    Now this might need another ticket. But I can't seem to get the store links to show in the sticky player.
    (I did add the stores to the tracks, but it isn't showing up in the sticky player)


    I am using base gutenburg for my site.

    I have supplied a screenshot of what I am doing.
    As you can see the post list there works and it it plays the songs that are attached to that playlist.
    I will add a play button and extra little custom styles.

    Cheers.


  •  1,103
    Max replied

    To add call to action links on your sticky player, you must add it through the custom fields in your post page. see screenshot: https://d.pr/i/9MpqVX

    Thanks,


    Max from the Sonaar.io Crew

  • Carson replied

    Hi Max,


    Thanks heaps for replying. 
    As I stated, I did this (like the way in your screenshot, in the tracks) and it doesn't seem to work.

    I also did a little digging and found that the code for my player has these sections commented out.

    In the second screenshot (player issue), left is the one on your demo page, right is my site.

    Would this be something I can fix?


  •  1,103
    Max replied

    sorry i dont really follow..

    any js error message in the console?

    give me page URL where I can reproduce the play that does not work

    Thanks,


    Max from the Sonaar.io Crew

  • Carson replied

    Hi Max,

    I will send the url in a private message just so google doesn't index it from this site.
    I don't want google indexing it yet.


    Thank you for your help and apologizes for the delay.


    Cheers,
    Carson. 

  •   Carson replied privately
  •  1,103
    Max replied

    Could you please explain what is the issue on the frontend ? When I go to your website and click play on the first album, the sticky player and the track start and I can hear it.

    Please describe steps to reproduce the issue on my end.


    Thanks,


    Max from the Sonaar.io Crew

  • Carson replied

    Hi Max,

    Thank you very much for testing but that is not what I am looking at here.

    I don't mean to be condescending but I did explain below this:

    > But I can't seem to get the store links to show in the sticky player.
    > (I did add the stores to the tracks, but it isn't showing up in the sticky player)

    The sticky player doesn't show the shop icons for each track.
    I added the stores to the tracks as seen in screenshot "track issue.png"
    and in screenshot:  player issue.png you can see that the code for the player is commenting out where the shop icons should be (Left is yours, right is mine.

    I guess there is some sort of javascript or some code that is blocking out these sections.

    Please let me know if you can understand this.
    Cheers,
    Carson.

  •  1,103
    Max replied

    If I understand correctly the issue, you say you have set buttons for "Where to buy / Download this Track" section for each of your track. see screenshot https://d.pr/i/SyFeYY and they dont appear in your sticky player?

    Could you please provide me access to your wp-admin and I will gladly check the issue you have.


    Thanks,


    Max from the Sonaar.io Crew

  • Carson replied

    Hi Max,

    Please mind my delay.
    I have had to put my own projects on hold.

    I was able to fix this myself.
    I had to add the shop in both the tracks and the album for it to work. 

    I am unsure why it had to be both and not just one or the other.

    Otherwise, thank you for your support in this matter.

  •  1,103
    Max replied

    The Track Links are displayed beside each tracks. 


    The album links are displayed only below playlist if external links options/attribute is enabled. 

    Thanks,


    Max from the Sonaar.io Crew