Giter VIP home page Giter VIP logo

larkplayer-vr's Introduction

larkplayer-vr

larkplayer 插件,用于播放 360º 全景视频

下载

CDN

<script type="text/javascript" src="https://unpkg.com/larkplayer-vr@latest/dist/larkplayer-vr.js"></script>

NPM

npm install larkplayer-vr

使用

<!DOCTYPE html>
<html>
<head>
    <title>larkplayer vr test</title>
    <meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no">
    <link rel="stylesheet" type="text/css" href="https://unpkg.com/larkplayer@latest/dist/larkplayer.css">

    <style type="text/css">
        body { margin: 0; padding: 0; }
    </style>
</head>
<body>
    <video id="video-el" src="https://dblate.github.io/larkplayer-vr/examples/mp4" loop></video>

    <script type="text/javascript" src="https://unpkg.com/larkplayer@latest/dist/larkplayer.js"></script>
    <script type="text/javascript" src="https://unpkg.com/larkplayer-vr@latest/dist/larkplayer-vr.js"></script>

    <script type="text/javascript">
        var width = Math.min(document.body.clientWidth, 640);
        var options = {};
        var player = larkplayer('video-el', {
            width: width,
            height: width * 9 / 16,
            plugin: {
                /**
                 * larkplayer-vr 配置
                 *
                 * @param {Object=} options 配置项,可选
                 * @param {number} options.height canvas 高度,默认为播放器高度 
                 * @param {number} options.width canvas 宽度,默认为播放器宽度
                 * @param {number} options.initialYaw 视频初始化时的角度,比如 45, 90, 180
                 * @param {Function} options.onError 出错时的回调函数
                 * @param {Function} options.onDragStart 拖动开始时的回调函数
                 * @param {Function} options.onDragStop 拖动结束时的回调函数
                 * @param {boolean} options.verticalPanning 禁用垂直平移,默认 false
                 */
                vr: options
            }
        });
        
        // 将镜头恢复到初始位置
        // player.plugin.vr.centralize();
        
        // 销毁插件
        // player.plugin.vr.dispose();
    </script>
</body>
</html>

兼容性

pc 端

  • chrome
  • safari
  • firefox
  • edge
  • ie11

移动端

  • chrome
  • safari

360 videos doesn't work in Safari, IE 11, Microsoft Edge, Android and iOS if the video is served from a different domain, due some CORS implementation bugs.

License

larkplayer-vr is under MIT LICENSE

larkplayer-vr's People

Contributors

dblate avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.