Web Player

Web Player

About the Widget

The Web Player widget puts an audio player for your stream on your web page. Visitors can listen to your stream in the web browser, without a separate media player.

The player has these controls:

  • The play button, which starts and stops playback.
  • A progress bar, which shows the progress of the current track if its length is known. For a file, the visitor can also use the bar to seek.
  • A volume slider.
  • A caption below the volume slider. By default, the caption is the title of your stream.

The player selects the stream format automatically. It uses the best format that the web browser of the visitor can play, from the formats that your streaming server supplies.

If the widget code names no mount point, the player plays the mount point /stream. To play a different mount point, select it in the Mount Point box of the Widgets page before you copy the code.

The On-demand Content widget also uses the Web Player widget to play files. For more information, see the On-demand Content section.

Widget Code

The anchor code is a <div> element with the class cc_player. Before the widget loads, the element shows the text Loading ....

The widget box has four option buttons. Each button changes one option in the advanced code:

  • Toggle seek bar
    Changes the showSeek option.

  • Toggle volume
    Changes the showVolume option.

  • Toggle caption
    Changes the showCaption option.

  • Toggle track details
    Changes the showTrack option.

Advanced Customization

Configurable Options

The advanced code sets these options:

  • autoplay
    Controls whether the player starts to play when the page loads. Note that most web browsers block automatic playback until the visitor interacts with the page. The default is false.

  • showSeek
    Controls whether the player shows the progress bar. For a file, the visitor can use the bar to seek. For a stream, the bar shows the progress of the current track, if the length of the track is known. The default is true.

  • showSeekTimes
    Controls whether the player shows the elapsed time and the total time below the progress bar. The default is true.

  • showTime
    Controls whether the player shows the elapsed time in place of the progress bar. This option has an effect only if showSeek is false. The default is false.

  • showVolume
    Controls whether the player shows the volume slider. The default is true.

  • showCaption
    Controls whether the player shows the caption below the volume slider. The default is true.

  • caption
    Specifies the text of the caption. If the value is empty, the caption is the title of your stream. The default is empty.

  • showTrack
    Controls whether the player shows the album cover, the title, the artist and the album of the current track above the controls. The default is false.

  • source
    Specifies a different audio source for the player. If url is empty, the player plays your stream. The default is an empty source. The source has these fields:

    • url
      Specifies the URL of the audio file or stream.

    • type
      Specifies the MIME type of the audio, for example audio/mpeg.

    • title
      Specifies the title of the audio.

  • manual
    Controls whether the player loads no audio by itself. If true, and source.url is empty, the player does not load your stream. Use this option only if a program on your page gives the audio to the player. The default is false.

  • unstyled
    Controls whether the widget applies its own styles. If true, the widget applies no styles, and your own CSS controls the appearance. The default is false.

Example: to show the track details, hide the volume slider, and use your own caption, use these values:

<script type="text/javascript">
(function(){ (window.$CC||(window.$CC={})).player = {

    autoplay: false,
    showSeek: true,
    showSeekTimes: true,
    showTime: false,
    showVolume: false,
    showCaption: true,
    caption: 'Listen live',
    showTrack: true,

};})();
</script>

CSS

The widget uses these CSS classes:

/* container for the default styles; not present if unstyled is true */
.cc_player_basic_style {
}
/* the track details, if showTrack is true */
.cc_player_track {
}
/* the title, the artist and the album of the current track */
.cc_player_track_title {
}
.cc_player_track_artist {
}
.cc_player_track_album {
}
/* the controls of the player */
.cc_player_controls {
}
/* the progress bar */
.cc_player_controls .seek {
}
/* the play button */
.cc_player_controls .mainbutton {
}
/* the volume slider and the caption */
.cc_player_controls .volume {
}
.cc_player_controls .caption {
}

Previous: Stream Directory
Section: Widgets