Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="text/javascript">
- DeviceDetection = function ()
- {
- this.construct = function (userAgent) {
- "undefined" == typeof userAgent && (userAgent = navigator.userAgent);
- this.userAgent = userAgent;
- this.checks = {
- iphone: Boolean(userAgent.match(/iPhone/)),
- ipod: Boolean(userAgent.match(/iPod/)),
- ipad: Boolean(userAgent.match(/iPad/)),
- blackberry: Boolean(userAgent.match(/BlackBerry/)),
- playbook: Boolean(userAgent.match(/PlayBook/)),
- android: Boolean(userAgent.match(/Android/)),
- macOS: Boolean(userAgent.match(/Mac OS X/)),
- win: Boolean(userAgent.match(/Windows/)),
- mac: Boolean(userAgent.match(/Macintosh/)),
- wphone: Boolean(userAgent.match(/(Windows Phone OS|Windows CE|Windows Mobile)/)),
- mobile: Boolean(userAgent.match(/Mobile/)),
- androidTablet: Boolean(userAgent.match(/(GT-P1000|SGH-T849|SHW-M180S)/)),
- tabletPc: Boolean(userAgent.match(/Tablet PC/)),
- palmDevice: Boolean(userAgent.match(/(PalmOS|PalmSource| Pre\/)/)),
- kindle: Boolean(userAgent.match(/(Kindle)/)),
- otherMobileHints: Boolean(userAgent.match(/(Opera Mini|IEMobile|SonyEricsson|smartphone)/))
- }
- };
- this.isTouchDevice = function () {
- return this.checks.iphone || this.checks.ipod || this.checks.ipad
- };
- this.isApple = function () {
- return this.checks.iphone || this.checks.ipod || this.checks.ipad || this.checks.macOS || this.checks.mac
- };
- this.isIOS = function () {
- return this.checks.iphone || this.checks.ipod || this.checks.ipad
- };
- this.isBlackberry = function () {
- return this.checks.blackberry
- };
- this.isAndroid = function () {
- return this.checks.android
- };
- this.isTablet = function () {
- return this.checks.ipad || this.checks.tabletPc || this.checks.playbook || this.checks.androidTablet || this.checks.kindle
- };
- this.isDesktop = function () {
- return !this.isTouchDevice() && !this.isSmartPhone() && !this.isTablet()
- };
- this.isSmartPhone = function () {
- return (this.checks.mobile || this.checks.blackberry || this.checks.palmDevice || this.checks.otherMobileHints) && !this.isTablet() && !this.checks.ipod
- };
- this.construct();
- return this
- };
- PlayLiveStreamOnDesktop = function (params)
- {
- jwplayer(params.container_id).setup({
- 'file': 'rtmp://' + params.service_identifier + '/live/_definst_/' + params.stream_name,
- 'width': params.width,
- 'height': params.height,
- });
- }
- PlayLiveStreamOnIOS = function (params)
- {
- $('#' + params.container_id).html($('<video/>', {
- 'src': 'http://' + params.service_identifier + '/live/_definst_/' + params.stream_name + '/playlist.m3u8',
- 'style': 'width: ' + params.width + 'px; height: ' + params.height + 'px; display: block;',
- 'text': 'Your browser does not support the video tag.' ,
- 'controls': true
- }));
- }
- PlayLiveStreamOnAndroid = function (params)
- {
- $('#' + params.container_id).html($('<a/>', {
- 'src': 'rtsp://' + params.service_identifier + '/live/_definst_/' + params.stream_name,
- 'style': 'width: ' + params.width + 'px; height: ' + params.height + 'px; display: block;',
- 'text': 'Your browser does not support the video tag.',
- 'controls': true
- }));
- }
- PlayVideoOnDesktop = function (params)
- {
- jwplayer(params.container_id).setup({
- 'file': 'rtmp://' + params.service_identifier + '/live/_definst_/' + params.video_format + ':' + params.stream_name,
- 'width': params.width,
- 'height': params.height
- });
- }
- PlayVideoOnIOS = function (params)
- {
- $('#' + params.container_id).html($('<video/>', {
- 'src': 'http://' + params.service_identifier + '/live/_definst_/' + params.video_format + ':' + params.stream_name + '/playlist.m3u8',
- 'style': 'width: ' + params.width + 'px; height: ' + params.height + 'px; display: block;',
- 'text': 'Your browser does not support the video tag.',
- 'controls': true
- }));
- }
- PlayVideoOnAndroid = function (params)
- {
- $('#' + params.container_id).html($('<video/>', {
- 'src': 'rtsp://' + params.service_identifier + '/live/_definst_/' + params.video_format + ':' + params.stream_name,
- 'style': 'width: ' + params.width + 'px; height: ' + params.height + 'px; display: block;',
- 'text': 'Your browser does not support the video tag.',
- 'controls': true
- }));
- }
- CDNsunLiveStreamWrapper = function (params)
- {
- detection = DeviceDetection();
- if(detection.isDesktop)
- {
- PlayLiveStreamOnDesktop(params);
- }
- else if(detection.isIOS())
- {
- PlayLiveStreamOnIOS(params);
- }
- else if(detection.isAndroid())
- {
- PlayLiveStreamOnAndroid(params);
- }
- else
- {
- alert('Unsupported device');
- }
- }
- $(document).ready(function(){
- CDNsunLiveStreamWrapper({
- 'container_id': "live",
- 'service_identifier': "81.20.17.30:1935",
- 'stream_name': 'krsu.stream',
- 'video_format': 'mp4',
- 'width': 100%,
- 'height': 420
- });
- });
- </script>
- <div id="live"></div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement