Brightcove Player Sample: Audio-Only

Product(s)
Video Cloud
Brightcove Player
Role(s)
Player Developer
Topic(s)
Audio

In this topic, you will learn to create a Brightcove player that plays your content in audio-only mode. The video still image is displayed during playback, so you won't see the video content, but you will hear the audio track.

Development sequence

Here is the recommended development sequence:

  1. Use the embed_in_page player implementation to test the functionality of your player, plugin and CSS (if CSS is needed)
  2. Put the plugin's JavaScript and CSS into separate files for local testing
  3. Deploy the plugin code and CSS to your server once you have worked out any errors
  4. Use Studio to add the plugin and CSS to your player
  5. Replace the embed_in_page player implementation if you determine that the iframe implementation is a better fit (detailed in next section)

For details about these steps, review the Quick Start to Plugin Development guide.

iframe or embed_in_page

When developing enhancements for the Brightcove player you will need to decide if the code is a best fit for the iframe or embed_in_page implementation. The best practice recommendation is to build a plugin for use with an iframe implementation. The advantages of using the iframe player are:

  • No collisions with existing JavaScript and/or CSS
  • Automatically responsive
  • The iframe eases use in social media apps (or whenever the video will need to "travel" into other apps)

Although integrating the embed_in_page player can be more complex, there are times when you will plan your code around that implementation. To generalize, this approach is best when the containing page needs to communicate to the player. Specifically, here are some examples:

  • Code in the containing page needs to listen for and act on player events
  • The player uses styles from the containing page
  • The iframe will cause application logic to fail, like a redirect from the containing page

Even if your final implementation does not use the iframe player, you can still use the embed_in_page player with a plugin that contains your JavaScript and CSS. This encapsulates your logic so that you can easily use it in multiple players.

Select implementation

Either an in-page or iframe player will work for this sample. Here, the iframe player is used

The player

See the Pen Audio-Only Player by Brightcove Learning Services (@rcrooks1969) on CodePen.

How it works

Publishing audio content in this way does not require any modification to your player. Just add an audio file to your Video Cloud library. Your audio content must be in the form of a MP4 video with no video track.

Create the player

To create a player and assign a video to it, follow these steps:

  1. In the Players module, create a new player or use an existing one.
  2. In the Media module, select an audio-only item and publish it with this player.Assign audio content to the player and publish it.
  3. Copy either the basic (iframe) or the advanced (In-Page) embed code and paste it into a new HTML file.
  4. Add the JavaScript to change the hover message on the play button from Play Video to Play Audio. For the advanced embed code you would need to create a custom plugin for the JavaScript.