Streaming Media
29 Jul 2014

Play live streams and videos on all devices – CDNsun Media Wrapper

CDNsun Media Wrapper

CDNsun Media Wrapper is a simple JW Player wrapper with device detection. The purpose of CDNsun Media Wrapper is to help you to play your live streams and videos on all devices. You can download the script at Services/How-To tab in the CDNsun client section.

Usage for live streams

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://p.jwpcdn.com/6/9/jwplayer.js"></script>
<script type="text/javascript" src="path-to-the-cdnsun-media-wrapper"></script>

<div id="mediaplayer"></div>

<script type="text/javascript">
    $(document).ready(function(){        
        CDNsunMediaWrapper({
            'media_type': 'live',
            'container_id': 'mediaplayer',
            'service_identifier': 995993821,
            'stream_name': 'mystream',
            'width': 480,
            'height': 320,
            'cover_image': 'cover_image.jpeg',
            'autostart': true
        });
    });
</script>

Replace mystream with the name of your stream, replace cover_image.jpeg with the location of your live stream cover image and replace path-to-the-cdnsun-media-wrapper with the location of your local copy of the CDNsun Media Wrapper.

Usage for video streams

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.9.0/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://p.jwpcdn.com/6/9/jwplayer.js"></script>
<script type="text/javascript" src="path-to-the-cdnsun-media-wrapper"></script>

<div id="mediaplayer"></div>

<script type="text/javascript">
    $(document).ready(function(){        
        CDNsunMediaWrapper({
            'media_type': 'video',
            'container_id': 'mediaplayer',
            'service_identifier': 995993821,
            'video_filename': 'myvideo.mp4',
            'video_format': 'mp4',
            'width': 480,
            'height': 320,
            'cover_image': 'cover_image.jpeg',
            'autostart': true
        });
    });
</script>

Replace myvideo.mp4 with the filename of your video, replace cover_image.jpeg with the location of your video cover image and replace path-to-the-cdnsun-media-wrapper with the location of your local copy of the CDNsun Media Wrapper. Note that only MP4 and FLV video files are supported.

Available debug options

The following options are available for debug purposes.

  • show_debug_info – true or false
  • force_protocol – rtmp, hls, rtsp, hds, smooth_streaming
  • force_player – jwplayer, atag, videotag

How does it work?

The CDNsun Media Wrapper detects your device by checking your User-Agent and based on that detection it initializes the appropriate player with the appropriate media URL. The current version of the CDNsun Media Wrapper initializes the JW Player on desktops (RTMP URL) and iOSes (HLS URL) and it initializes a clickable a tag (RTSP URL) on Androids and other smartphones.

We would love your feedback!

We would love your feedback, it helps us to improve future versions of the CDNsun Media Wrapper. Please provide your feedback by sending an email to support [at] cdnsun.com or please contact our 24/7 live chat support at the CDNsun website.

Sincerely your CDNsun team.