1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Audios in Posts?

Discussion in 'General XenForo Discussion and Feedback' started by Core Freedom, Dec 27, 2012.

  1. Core Freedom

    Core Freedom Well-Known Member

    I'd like to publish my podcasts in my posts, is this possible with XF?
     
  2. Edrondol

    Edrondol Well-Known Member

    Are you using a service (Soundcloud, talkshoe, etc.) or simply uploading the MP3 files?
     
    Core Freedom likes this.
  3. Core Freedom

    Core Freedom Well-Known Member

    That's what I'm trying to figure out. Do I need anything in order to post MP3s? And how can I post MP3s through these services?
     
  4. MattW

    MattW Well-Known Member

    You can get a free sound cloud account which will let you host 2 hours worth of tracks. You can then link those into your posts with a custom BBCode to pull the html5 player into the post.

    I do this when posting links to my mixes on my site
    SoundCloud.PNG
     
    RichardGaspa and Core Freedom like this.
  5. Edrondol

    Edrondol Well-Known Member

    If you try and do MP3s I think there is an addon for it but I'd have to look. The two other ways I mentioned are already doable easily, but each requires you to put in a popular addon.

    Soundcloud - Uses BBCode MediaSites Package addon. Simply paste the url of the file and it'll have a player right in the post.

    Talkshoe - If you'd rather have a widget, you can create a Talkshoe account and then add their custom widget to your site.

    I have both on my site and you are welcome to take a look.

    edit: I just tried to upload something from SoundCloud and it seems the BBCode is no longer working. So I have to take a look at that.
     
    Core Freedom likes this.
  6. Edrondol

    Edrondol Well-Known Member

    Did your Soundcloud change? Mine doesn't work on my site any more. Maybe a change to the way that the BBCode parses?
     
    Core Freedom likes this.
  7. MattW

    MattW Well-Known Member

    Yes, I had to change it to use the html5 player.

    CallBack:
    PHP:
    <?php
    class MediaSites_Soundcloud
    {
            public static function 
    buildEmbed($mediaKey, array $site)
            {
                    
    $pageHtml file_get_contents('http://soundcloud.com/' $mediaKey );
            if(
    preg_match('#<meta.+player.swf\?url=.+tracks%2F(?P<scid>[0-9]+)#si'$pageHtml$match))
            {
                            
    $embedHtml '<iframe width="100%" height="166" class="html5player" scrolling="no" frameborder="no" src="htt
    p://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F__MEDIAKEY__&show_artwork=true"></iframe>'
    ;
                            
    $finalHtml str_replace('__MEDIAKEY__'$match['scid'], $embedHtml);
                            return 
    $finalHtml;
                    }
                    elseif(
    preg_match('#<meta.+player.swf\?url=.+playlists%2F(?P<scid>[0-9]+)#si'$pageHtml$match))
                            {
                            
    $embedHtml '<iframe width="100%" height="450" class="html5player" scrolling="no" frameborder="no" src="htt
    p://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F__MEDIAKEY__&show_artwork=true"></iframe>'
    ;
                            
    $finalHtml str_replace('__MEDIAKEY__'$match['scid'], $embedHtml);
                            return 
    $finalHtml;
                    }
                    elseif(
    preg_match('#<meta.+player.swf\?url=.+users%2F(?P<scid>[0-9]+)#si'$pageHtml$match))
                    {
                            
    $embedHtml '<iframe width="100%" height="450" class="html5player" scrolling="no" frameborder="no" src="htt
    p://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F__MEDIAKEY__&show_artwork=true"></iframe>'
    ;
                            
    $finalHtml str_replace('__MEDIAKEY__'$match['scid'], $embedHtml);
                            return 
    $finalHtml;
                    }
                    else return 
    '<a href="http://soundcloud.com/' $mediaKey '">http://soundcloud.com/' $mediaKey '</a>';
            }
    }
    SoundCloud1.PNG SoundCloud2.PNG
     
    3rd AnGle and Core Freedom like this.
  8. Edrondol

    Edrondol Well-Known Member

    Yeeowch! Thanks, man. That's...complicated. :)
     
    Core Freedom and MattW like this.
  9. Edrondol

    Edrondol Well-Known Member

    So you had to create a Soundcloud php file and put it in your MediaSites directory?
     
    Core Freedom likes this.
  10. MattW

    MattW Well-Known Member

    Yep:
    forum/library/MediaSites/Soundcloud.php
     
    adwade and Core Freedom like this.
  11. Edrondol

    Edrondol Well-Known Member

  12. EQnoble

    EQnoble Well-Known Member

    I did the soundcloud bbcode a long time ago...and I did switch it to use the html 5


    in fact this is my code...

    PHP:
    <?php
    class MediaSites_Soundcloud
    {
        public static function 
    buildEmbed($mediaKey, array $site)
        {
            
    $pageHtml file_get_contents'http://' $mediaKey );
            if(
    preg_match('#<meta.+player.swf\?url=.+tracks%2F(?P<scid>[0-9]+)#i'$pageHtml$match))
            {
                
    $embedHtml '<iframe width="100%" height="166" class="html5player" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Ftracks%2F__MEDIAKEY__&show_artwork=true"></iframe>';
                
    $finalHtml str_replace('__MEDIAKEY__'$match['scid'], $embedHtml);
                return 
    $finalHtml;
            }
            elseif(
    preg_match('#<meta.+player.swf\?url=.+playlists%2F(?P<scid>[0-9]+)#i'$pageHtml$match))
                {
                
    $embedHtml '<iframe width="100%" height="450" class="html5player" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F__MEDIAKEY__&show_artwork=true"></iframe>';
                
    $finalHtml str_replace('__MEDIAKEY__'$match['scid'], $embedHtml);
                return 
    $finalHtml;
            }
            elseif(
    preg_match('#<meta.+player.swf\?url=.+users%2F(?P<scid>[0-9]+)#i'$pageHtml$match))
            {
                
    $embedHtml '<iframe width="100%" height="450" class="html5player" scrolling="no" frameborder="no" src="http://w.soundcloud.com/player/?url=http%3A%2F%2Fapi.soundcloud.com%2Fusers%2F__MEDIAKEY__&show_artwork=true"></iframe>';
                
    $finalHtml str_replace('__MEDIAKEY__'$match['scid'], $embedHtml);
                return 
    $finalHtml;
            }
            else return 
    '<a href="http://' $mediaKey '">http://' $mediaKey '</a>';   
        }
    }
     
    Core Freedom and MattW like this.
  13. MsJacquiiC

    MsJacquiiC Well-Known Member

    Core Freedom and Edrondol like this.
  14. Edrondol

    Edrondol Well-Known Member

    I knew I'd seen something!
     
    Core Freedom and MsJacquiiC like this.
  15. EQnoble

    EQnoble Well-Known Member

    I also have an mp3 player that offloads the files when not playing so that none of the files actually load on page load...when you click the container for the song the audio file is loaded into that instance of the player container...

    I have to run out but when I get back I will look it up here on my end....if you are interested shoot me a convo titled MP3 with a link to this thread in the body of it to remind me when i sit down after getting back home and maybe I will find it.
     
    3rd AnGle and Core Freedom like this.
  16. MsJacquiiC

    MsJacquiiC Well-Known Member

    lol - it was hidden deep in the resources LOL

    hmmm - sounds interesting! I'd certainly be interested :)
     
    Core Freedom likes this.
  17. Core Freedom

    Core Freedom Well-Known Member

    Thanks everyone! My head is spinning and I definitely need to stay away from code of any sorts, don't have the experience. I was hoping to just post something like [podcast] like we can in Wordpress. I guess it's not that easy. My podcasts are for lessons, 1 to 1.5 hours each, and they're part of a course that people pay for their membership for. Ideally the player is visible in the post so they can hit "play" etc. Will check out these resources but definitely need something for a non-techie. :)
     
  18. Edrondol

    Edrondol Well-Known Member

    Then my suggestion would be to get a Talkshoe account at www.talkshoe.com, upload the mp3 files, and put the widget on your sidebar.

    If you decided the Soundcloud thing would work better, I'd be willing to help you get it running.

    I've attached the php file just in case. Also, because it was a pain in the butt to type in, here's the URL Match for the Soundcloud stuff:

    Code:
    #soundcloud\.com/(?P<id>([a-z0-9-_]+/[a-z0-9-_]+/[a-z0-9-_]+)|[a-z0-9-_]+/[a-z0-9-_]+)#si
     

    Attached Files:

    Core Freedom and MattW like this.
  19. Core Freedom

    Core Freedom Well-Known Member

    Thank you, Edrondol! The sidebar thingy doesn't work since these podcasts are not music but my lessons, so they need to be "hidden" in posts that are for upgrade members only. Each of these podcasts are 75 MB in size and I do at least one per week. So having them hosted elsewhere is key. I just want an EASY way of placing the player in the actual post for people. Will research both sources. Thank you!
     
  20. Edrondol

    Edrondol Well-Known Member

    Hmm. With Soundcloud you only get 120 minutes total unless you want to pay. (http://soundcloud.com/premium) So I think looking into MP3 capabilities would work best for you. Let me see what else I find.
     
    Core Freedom likes this.

Share This Page