您的位置:首页技术文章
文章详情页

如何在手机端中使用HTML5插入flv格式的视频

浏览:36日期:2022-11-30 18:30:33

问题描述

想要在用HTML5开发的软件中的登录页面使用flv格式的视频作为背景播放,想问一下怎么实现。我查过挺多帖子都说HTML5并不支持flv格式的视频,但是又不能用MP4格式的,因为视频要放在本地安装包中,要求视频尽量不超过3M,问问大神们怎么解决这个问题。感谢

问题解答

回答1:

不超过 3M ,可以通过重新解码再编码 mp4 来实现,HTML5 播放 flv 就不要考虑了,难度太大。

回答2:

先说结果:可行。预览地址:我临时在个人站点上提供一个预览链接,三天后删除

http://alonesuperman.com/show...

用到了b站开源的flv.jshttps://github.com/Bilibili/f...刚才自己改了下demo给你看看

<!DOCTYPE html><html><head> <meta content='text/html; charset=utf-8' http-equiv='Content-Type'> <title>flv.js demo2</title> <style>.mainContainer { display: block; width: 1024px; margin-left: auto; margin-right: auto;}.urlInput { display: block; width: 100%; margin-left: auto; margin-right: auto; margin-top: 8px; margin-bottom: 8px;}.centeredVideo { display: block; width: 100%; height: 576px; margin-left: auto; margin-right: auto; margin-bottom: auto;}.controls { display: block; width: 100%; text-align: left; margin-left: auto; margin-right: auto;} </style></head><body><p class='mainContainer'><video name='videoElement' controls autoplay height='576'> Your browser is too old which doesn’t support HTML5 video.</video><br><p class='controls'> <button onclick='flv_load()'>Load</button> <button onclick='flv_start()'>Start</button> <button onclick='flv_pause()'>Pause</button> <button onclick='flv_destroy()'>Destroy</button> <input type='text' name='seekpoint'/> <button onclick='flv_seekto()'>SeekTo</button></p> </p> <script src='https://www.haobala.com/dist/flv.js'></script><script>function flv_load() { if (flvjs.isSupported()) {var videoElement = document.getElementById(’videoElement’);var flvPlayer = flvjs.createPlayer({ type: ’flv’, url: ’1.flv’});flvPlayer.attachMediaElement(videoElement);flvPlayer.load();flvPlayer.play(); } window.player=flvPlayer;}function flv_start() { player.play();}function flv_pause() { player.pause();}function flv_destroy() { player.pause(); player.unload(); player.detachMediaElement(); player.destroy(); player = null;}function flv_seekto() { var input = document.getElementsByName(’seekpoint’)[0]; player.currentTime = parseFloat(input.value);}function getUrlParam(key, defaultValue) { var pageUrl = window.location.search.substring(1); var pairs = pageUrl.split(’&’); for (var i = 0; i < pairs.length; i++) {var keyAndValue = pairs[i].split(’=’);if (keyAndValue[0] === key) { return keyAndValue[1];} } return defaultValue;} </script> </body></html>

如何在手机端中使用HTML5插入flv格式的视频

如何在手机端中使用HTML5插入flv格式的视频

回答3:

不存在的!!!!!

标签: Html5
相关文章: