Enclosure Support in BlogEngine (Part 2)

Quick follow up on enclosure support in the latest BE build. I made a slight change to make it easier to use and better play with multiple extensions – the media directory location setting has been deprecated. BE will turn your media file into enclosure no matter where you put it - as long as it is local to your server and valid (physically exists).

Basic logic

  • If enclosure support turned on (checked in the admin/settings)
  • For all supported media formats
  • For each posts
  • If post has link to media file of this format
  • If this file physically exists on the server
  • Create enclosure for this file

Mini Q&A session

Do I need extension to use enclosure?

No, you can simply upload media file anywhere on your blog and add a link to this file in your post – BE will turn it into enclosure when serving the feed.

Why would I need an extension?

Extensions can be used to let visitors play media files on the site. Extension can “automatically” (from the user perspective) inject link to media file into the RSS feed and BE will turn it into enclosure.

I’m writing a media player extension, what do I do to make it support enclosures?

In your extension, you’ll need to parse post and, on feed serving, instead of loading player, write link to the media file. Here is an example:

if (e.Location == ServingLocation.Feed)
{
   // inject link
   string link = "<a href=\"{0}\">{1}</a>";
   link = string.Format(link, url, filename);
   e.Body = e.Body.Replace(match.Value, link);
}
else
{
   //TODO: inject player in the post
}

What media types support enclosures?

Supported types include "m4a", "mp3", "mov", "mp4", "m4v", and "pdf".

Do you support multiple enclosures?

Some RSS readers support multiple enclosures, others do not. Single enclosure support is a lower denominator – we will stick with singles until multiple enclosures become mainstream (if ever). BE will break loop after finding link to the first valid media file in the blog post.

Can't find answer on your question?

Leave a comment :)

Where I can get more information?

Check out podcasting technical specifications on iTunes site.

About RTUR.NET

This site is all about developing web applications with focus on designing and building open source blogging solutions. Technologies include ASP.NET Core, C#, Angular, JavaScript and more.