Share excellent template plug-in resources
Current position: home page > Website Design >Use JS code to adapt the player code of computer and mobile phone

Use JS code to adapt the player code of computer and mobile phone

Author: blueleaf Classification: Website Design Time: August 10, 2016 Browse: 12669 Comments: 9

With the rise of html5, many websites are designed with html5 code to make websites beautiful and grand. However, html5 code can only be displayed by browsers that support html5. Now a large number of people still use old IE browsers, especially all enterprise customers. Their websites must also be compatible with the old version of IE browsers; Take the player for example. There are many good looking players on the Internet Html5 Player , works well under the html5 browser, but does not support the old IE browser. In this case, the best way is to use the flash player on the computer side instead, and use the native html5 music video tag on the mobile side to play, which saves time and effort and does not need to worry about the display effect of each browser, The following is a piece of JS code to adapt the computer side and mobile phone side to different players.

 Add the following code before</head>: <script src=" http://apps.bdimg.com/libs/ jquery /1.7.1/jquery.min.js" type="text/ javascript "></script> <script type="text/javascript"> $(document).ready(function(){ $(".playbox").each(function() { var playsrc = $(this).attr('data-u'); var playwidth = $(this).attr('data-w'); var playheight = $(this).attr('data-h'); if ((navigator.userAgent.match(/(iPhone|iPod|Android|ios|iOS|iPad|Backerry|WebOS|Symbian|Windows Phone|Phone)/i))) {  $(this).html('<video width="'+playwidth+'" height="'+playheight+'" src="'+playsrc+'" controls></video>'); }else{ $(this).html('<embed wmode="transparent" width="'+playwidth+'" height="'+playheight+'" src=" https://lanye.org/demo/Lyplayer.swf?path= '+playsrc+'&type=flv&fullscreen=true&autoplay=false&backcolor=99ff33&amp; frontcolor=ffffff" type="application/x-shockwave-flash" quality="high" allowfullscreen="true">');   } }) }) </script> Add the following code to the content: data-u is the music video address, data-w is the player width, and data-h is the player height. <div class="playbox" data-u="music or video address" data-w="width" data-h="height"></div>

Disclaimer:

Website: Click Copy to share with friends!

All content resources shared by this website, if not noted, are original by Blueleaf. If you need to reprint, please indicate the source; Please contact us in case of infringement Contact handling Please understand!

Comment List
 blink the eyes kiss Growl happy think poor It's embarrassing Grievance ha-ha hush Right hum Zuo Hum Hum doubt A bad laugh Make money Sadness Be cool Seduce fierce handshake yeah Hee hee Shyness applause greedy Madness Embrace gather and watch Mighty awesome
Submit comments

Clear information
Close Comment
 nmshuang
nmshuang tourist
#5
Can this player code play FLV video?
2018-04-12 22:27 reply
 blueleaf
blueleaf tourist
@Nmshuang: Yes, it is better to use the H264 encoded mp4 format for web video.
2018-04-14 16:33 reply
 one thousand one hundred and twenty-four
one thousand one hundred and twenty-four tourist
@Blueleaf: Can you make the video play in cycles
2018-07-13 14:42 reply
 blueleaf
blueleaf tourist
@1124: add loop in video tag
2018-07-21 09:58 reply
 Funny Resources
Funny Resources tourist
#4
excellent
2017-02-04 18:41 reply
 Yangyao We Media
Yangyao We Media tourist
#3
This can have,
2016-11-09 20:40 reply
 years
years tourist
#2
Wow, very supportive
2016-10-03 21:04 reply
 Suppore
Suppore tourist
#1
Nice sharing.
PS: Sorry for sharing Brother Ye's works without permission.
2016-08-10 11:00 reply
 Multi wing
Multi wing tourist
@Suppore: Good Youth
2016-08-13 00:00 reply
music appreciation