Mobile detection for specific parts of websites

夙愿已清 提交于 2019-12-02 08:56:08

The video tag already supports alternate sources. The article here describes how to include multiple sources for a video (because some browsers don't work with certain codecs). Like so:

<video width="320" height="240" controls>
  <source src="movie.mp4" type="video/mp4">
  <source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>

For mobile checks you can use JavaScript CSS media queries:

function isMobile() {
    return window.matchMedia( "(max-width: 320px)" );
}

See this article

Offbeatmammal

you could either use UserAgent based detection to decide what to show (not recommended as you have to maintain it) or canPlayType() with the codec you are using to see if the browser supports it (better option)

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!