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

Audios in Posts?

MattW

Well-known member
#4
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
 

Edrondol

Well-known member
#5
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.
 

MattW

Well-known member
#7
Did your Soundcloud change? Mine doesn't work on my site any more. Maybe a change to the way that the BBCode parses?
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
 

EQnoble

Well-known member
#12
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>';   
    }
}
 

EQnoble

Well-known member
#15
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.
 

MsJacquiiC

Well-known member
#16
I knew I'd seen something!
lol - it was hidden deep in the resources LOL

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.
hmmm - sounds interesting! I'd certainly be interested :)
 

Core Freedom

Well-known member
#17
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. :)
 

Edrondol

Well-known member
#18
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
 

Attachments

Core Freedom

Well-known member
#19
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!