请选择 进入手机版 | 继续访问电脑版
帖子
帖子
用户
博客
课程
显示全部楼层
216
帖子
5
勋章
5750
Y币

floatWords模块demo示例

[复制链接]
发表于 2022-7-24 08:52:07

floatWords模块使用画中画功能实现了iOS、Android悬浮提词显示功能。

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <title>Module Develop</title>
  5. <meta charset="utf-8">
  6. <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
  7. <style type="text/css">
  8.         html,body{
  9.                 height: 100%
  10.         }
  11.         body{
  12.                 background-color: #fff;
  13.             margin: 0;
  14.         }
  15.         #wrap{
  16.             height: 100%;
  17.             position: relative;
  18.         }
  19.         #header{
  20.                 background-color: #5082c2;
  21.                 height: 44px;
  22.             position: relative;
  23.         }
  24.         #header h1{
  25.             font-size: 20px;
  26.             height: 44px;
  27.             line-height: 44px;
  28.             margin: 0em;
  29.             color: #fff;
  30.                 margin-left: 100px;
  31.                 margin-right: 100px;
  32.                 text-align: center;
  33.         }
  34.     #main{
  35.         display: block;
  36.     }
  37.     a.button{
  38.         display: -webkit-box;
  39.         -webkit-box-pack: center;
  40.         -webkit-box-align: center;
  41.         height: 36px;
  42.         margin: 8px;
  43.         background-color: rgba(240,240,240,1.0);
  44.         border-color: rgba(220,220,220,1.0);
  45.         border-width: 2px;
  46.         border-style: solid;
  47.         }
  48.     a.active{
  49.         background-color: rgba(240,240,240,0.6);
  50.         }
  51. </style>
  52. </head>
  53. <body>
  54.         <div id="wrap">
  55.             <header id="header">
  56.                     <h1 id="title">模块开发</h1>
  57.             </header>
  58.             <div id="main">
  59.             <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
  60.             <a class="button" tapmode="active" onclick="canDrawOverlays()">canDrawOverlays</a>
  61.             <a class="button" tapmode="active" onclick="openView()">预览提词视图</a>
  62.             <a class="button" tapmode="active" onclick="hideView()">隐藏提词视图</a>
  63.             <a class="button" tapmode="active" onclick="showView()">隐藏后显示提词视图</a>
  64.             <a class="button" tapmode="active" onclick="closeView()">关闭提词视图</a>
  65.             <a class="button" tapmode="active" onclick="startPlay()">开始滚动播放</a>
  66.             <a class="button" tapmode="active" onclick="stopPlay()">停止滚动播放</a>
  67.             <a class="button" tapmode="active" onclick="startPIP(0)">开启画中画0</a>
  68.             <a class="button" tapmode="active" onclick="startPIP(1)">开启画中画1</a>
  69.             <a class="button" tapmode="active" onclick="startPIP(2)">开启画中画2</a>
  70.             <a class="button" tapmode="active" onclick="startPIP(3)">开启画中画3</a>
  71.             <a class="button" tapmode="active" onclick="startPIP(4)">开启画中画4</a>
  72.             <a class="button" tapmode="active" onclick="stopPIP()">停止画中画</a>
  73.             <a class="button" tapmode="active" onclick="updateStyle1()">更新样式1</a>
  74.             <a class="button" tapmode="active" onclick="updateStyle2()">更新样式2</a>
  75.             <a class="button" tapmode="active" onclick="updateSpeed(10)">更新速度1</a>
  76.             <a class="button" tapmode="active" onclick="updateSpeed(50)">更新速度2</a>
  77.             <a class="button" tapmode="active" onclick="updateSpeed(100)">更新速度3</a>
  78.             <br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
  79.         </div>
  80.     </div>
  81. </body>
  82. <script>
  83.     var demo;

  84.     function canDrawOverlays() {
  85.         demo.canDrawOverlays(function(ret, err){
  86.             alert(JSON.stringify(ret));
  87.         });
  88.     }

  89.     function openView() {
  90.         demo.openView({
  91.             rect : {
  92.                 x : 20,
  93.                 y : 50,
  94.                 w: api.frameWidth - 40,
  95.                 h: api.frameHeight/3
  96.             },
  97.             fixedOn: api.frameName,
  98.             fixed: true,
  99.             //text : '文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n '
  100.             text : '\n1\n2\n3\n4\n5\n6\n7\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view\n文本文本文本文本文本文本文本文本文本文本文本文本可以放任意view'
  101.         },function(ret, err){
  102.             alert(JSON.stringify(ret));
  103.         });
  104.     }

  105.     function hideView() {
  106.         demo.hideView(function(ret, err){
  107.             alert(JSON.stringify(ret));
  108.         });
  109.     }
  110.    
  111.     function showView() {
  112.         demo.showView(function(ret, err){
  113.             alert(JSON.stringify(ret));
  114.         });
  115.     }
  116.    
  117.     function closeView() {
  118.         demo.closeView(function(ret, err){
  119.             alert(JSON.stringify(ret));
  120.         });
  121.     }
  122.    
  123.     function startPlay() {
  124.         var ret = demo.startPlay();
  125.         alert(JSON.stringify(ret));
  126.     }
  127.    
  128.     function stopPlay() {
  129.         var ret = demo.stopPlay();
  130.         alert(JSON.stringify(ret));
  131.     }
  132.    
  133.     function startPIP(type) {
  134.         demo.startPIP({
  135.             videoType : type,
  136.             countDown : 6,
  137.         },function(ret, err){
  138.             alert(JSON.stringify(ret));
  139.         });
  140.     }
  141.    
  142.     function stopPIP() {
  143.         var ret = demo.stopPIP();
  144.         alert(JSON.stringify(ret));
  145.     }

  146.     function updateStyle1() {
  147.         var ret = demo.updateStyle({
  148.             backgroundColor: '#FFFFFF',
  149.             textFontColor: '#000000',
  150.             textFontSize: 30,
  151.         });
  152.         alert(JSON.stringify(ret));
  153.     }
  154.    
  155.    
  156.     function updateStyle2() {
  157.         var ret = demo.updateStyle({
  158.             backgroundColor: '#FFB6C1',
  159.             textFontColor: '#DA70D6',
  160.             textFontSize: 14,
  161.         });
  162.         alert(JSON.stringify(ret));
  163.     }
  164.    
  165.     function updateSpeed(s) {
  166.         var ret = demo.updateSpeed({
  167.             speed: s,
  168.         });
  169.         alert(JSON.stringify(ret));
  170.     }
  171.    
  172. function apiready() {
  173.     var header = document.getElementById('header');
  174.     header.style.paddingTop = api.safeArea.top + 'px';
  175.    
  176.     api.removeLaunchView();
  177.    
  178.     demo = api.require('floatWords');
  179. }
  180. </script>
  181. </html>
复制代码


您需要登录后才可以回帖 登录

本版积分规则