|
scrollVideo模块用ijkplayer封装在iOS、Android下仿抖音上下滑动播放视频功能(列表图片加载会存在延迟,可能会出现黑屏,属于正常现象,后续优化;iOS可以无限循环播放,Android没有无限循环播放功能)。
点击进入模块详情
- <!DOCTYPE html>
- <html>
- <head>
- <title>Module Develop</title>
- <meta charset="utf-8">
- <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
- <style type="text/css">
- html, body {
- height: 100%
- }
- body {
- background-color: #fff;
- margin: 0;
- }
- #wrap {
- height: 100%;
- position: relative;
- }
- #header {
- padding-top: 20px;
- background-color: #5082c2;
- height: 44px;
- position: relative;
- }
- #header h1 {
- font-size: 20px;
- height: 44px;
- line-height: 44px;
- margin: 0em;
- color: #fff;
- margin-left: 100px;
- margin-right: 100px;
- text-align: center;
- }
- #main {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- }
- a.button {
- display: -webkit-box;
- -webkit-box-orient: vertical;
- -webkit-box-pack: center;
- -webkit-box-align: center;
- height: 32px;
- margin: 8px;
- background-color: rgba(240,240,240,1.0);
- border-color: rgba(220,220,220,1.0);
- border-width: 2px;
- border-style: solid;
- }
- a.active {
- background-color: rgba(240,240,240,0.7);
- }
- </style>
- </head>
- <body>
- <div id="wrap">
- <div id="main">
- <a class="button" tapmode="active" onclick="_addEventListener()" >滑动播放器监听</a>
- <a class="button" tapmode="active" onclick="openScrollVideo()" >打开滑动播放器</a>
- <a class="button" tapmode="active" onclick="hideScrollVideo()" >隐藏滑动播放器</a>
- <a class="button" tapmode="active" onclick="showScrollVideo()" >显示滑动播放器</a>
- <a class="button" tapmode="active" onclick="closeScrollVideo()" >关闭滑动播放器</a>
- <a class="button" tapmode="active" onclick="addVideoData()" >添加一条记录</a>
- <a class="button" tapmode="active" onclick="pause()" >暂停播放</a>
- <a class="button" tapmode="active" onclick="play()" >暂停后继续播放</a>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- <br>
- </div>
- </div>
- </body>
- <script type="text/javascript">
- var demo = null;
- apiready = function() {
- demo = api.require('scrollVideo');
- if (!demo) {
- alert("请添加模块后编译");
- return;
- }
- }
- function _addEventListener() {
- demo.addEventListener(function(ret, err) {
- console.log(JSON.stringify(ret));
- api.toast({
- msg : JSON.stringify(ret)
- });
- });
- }
- function openScrollVideo() {
- demo.openScrollVideo({
- rect : {
- x : 0,
- y : 150,
- h : 400
- },
- userData : [{
- uid : new Date().getTime() + 1,
- imageUrl : 'http://**.**1.z0.glb**.**/apicloud/bc281dfcaf750de7acd9c8e9224e237b.png',
- videoUrl : 'http://apiclouddelimg.oss-cn-beijing.aliyuncs.com/VID_20181101_152546.mp4',
- isLocalCache : true
- }, {
- uid : new Date().getTime() + 2,
- imageUrl : 'http://**.**1.z0.glb**.**/apicloud/1a73dd6a90a52b2aad1aafefbf977e4c.png',
- videoUrl : 'http://**.**1.z0.glb**.**/apicloud/00b2141bff87cfaa75498f66214aeb9e.mp4',
- isLocalCache : true
- }, {
- uid : new Date().getTime() + 3,
- imageUrl : 'http://**.**1.z0.glb**.**/apicloud/ec65083dbdc6bb18a6318591ac6c15a5.png',
- videoUrl : 'http://**.**1.z0.glb**.**/apicloud/9d9906ba474152307d7edca6bd72fbe2.mp4',
- isLocalCache : true
- }, {
- uid : new Date().getTime() + 4,
- imageUrl : 'http://**.**1.z0.glb**.**/apicloud/51fc1ddde9790c96a6986b74342a15e3.png',
- videoUrl : 'http://**.**1.z0.glb**.**/apicloud/dc811d2c4d88b409063c7ea2065fe6a0.mp4',
- isLocalCache : true
- }, {
- uid : new Date().getTime() + 5,
- imageUrl : 'http://**.**1.z0.glb**.**/apicloud/51fc1ddde9790c96a6986b74342a15e3.png',
- videoUrl : 'http://**.**1.z0.glb**.**/apicloud/dc811d2c4d88b409063c7ea2065fe6a0.mp4',
- isLocalCache : true
- }],
- backgroundColor : '',
- }, function(ret, err) {
- alert(JSON.stringify(ret) + " " + JSON.stringify(err));
- });
- }
- function addVideoData() {
- demo.addVideoData({
- uid : new Date().getTime() + 6,
- imageUrl : 'http://**.**1.z0.glb**.**/apicloud/51fc1ddde9790c96a6986b74342a15e3.png',
- videoUrl : 'http://**.**1.z0.glb**.**/apicloud/dc811d2c4d88b409063c7ea2065fe6a0.mp4',
- isLocalCache : true
- }, function(ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function hideScrollVideo() {
- demo.hideScrollVideo(function(ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function showScrollVideo() {
- demo.showScrollVideo(function(ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function closeScrollVideo() {
- demo.closeScrollVideo(function(ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function pause() {
- demo.pause(function(ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- function play() {
- demo.play(function(ret, err) {
- alert(JSON.stringify(ret));
- });
- }
- </script>
- </html>
复制代码
|
|