App-Android(使用App+htnl5框架,解决消息推送兼容SignalR问题)
loulijun2021
2022-09-18 e5d34f5c51e4a852e67d24709ec7e7b708846066
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
<!DOCTYPE HTML>
<html>
    <head>
        <meta charset="utf-8"/>
        <meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
        <meta name="HandheldFriendly" content="true"/>
        <meta name="MobileOptimized" content="320"/>
        <title>Hello H5+</title>
        <script type="text/javascript" src="../js/common.js"></script>
        <script type="text/javascript">
var video = null;
var playing = false;
// H5 plus事件处理
function plusReady(){
    // 创建视频播放控件
    video = new plus.video.VideoPlayer('video',{
        src:'../video/bee.mp4'
    });
    video.addEventListener('play', function(){
        updatePlaying(true);
    }, false);
    video.addEventListener('pause', function(){
        updatePlaying(false);
    }, false);
}
document.addEventListener('plusready', plusReady, false);
// 播放
function playVideo1() {
    var path = document.getElementById('path1').value;
    if(path&&path.length>0) {
        video.setOptions({src:path});
        video.play();
    }
}
function playVideo2() {
    var path = document.getElementById('path2').value;
    if(path&&path.length>0) {
        video.setOptions({src:path});
        video.play();
    }
}
function updateVideo() {
    video.setStyles({direction:0});
}
// 更新为播放状态
function updatePlaying(play) {
    playing = play;
    document.getElementById('pp').innerText = playing?'暂停':'播放';
}
// 播放/暂停
function ppVideo() {
    playing?video.pause():video.play();
}
// 全屏
function fullscreenVideo() {
    video.requestFullScreen(-90);
}
// 切换倍速
var ri = 2;
var ra = [0.5,0.8,1.0,1.25,1.5,2];
function switchRate() {
    ri++;
    if(ri>=ra.length){
        ri = 0;
    }
    video.playbackRate(ra[ri]);
    document.getElementById('rate').innerText = '切换倍速('+ra[ri]+')';
}
// 创建子创建覆盖在视频控件上
var wsub = null;
function createSubview(){
    if(!wsub) {
        var topoffset = document.getElementById('video').offsetTop;
        wsub=plus.webview.create('video_videoplayer_sub.html','sub',{top:topoffset,height:'300px',position:'static',scrollIndicator:'none',background:'transparent'});
        plus.webview.currentWebview().append(wsub);
    }
    wsub.isVisible()?wsub.hide():wsub.show();
}
        </script>
        <link rel="stylesheet" href="../css/common.css" type="text/css" charset="utf-8"/>
        <style type="text/css">
input {
    width:70%;
    font-size: 16px;
    padding: .2em .2em;
    border: 1px solid #00B100;
    -webkit-user-select: text;
}
button {
    width:20%;
    margin:6px 0 6px 6px;
    font-size: 16px;
    color: #FFF;
    background-color: #00CC00;
    border: 1px solid #00B100;
    padding: .2em 0em;
    -webkit-border-radius: 5px;
    border-radius: 5px;
}
 
        </style>
    </head>
    <body>
        <br/>
        <div id="video" style="width:98%;height:300px;background-color:#000000;margin:auto"></div>
        <br/>
        <div style="text-align:center; margin:auto;">
            <!--<input id="path1" type="text" value="http://vjs.zencdn.net/v/oceans.mp4" placeholder="请输入视频地址,支持mp4/flv格式"/>-->
            <input id="path1" type="text" value="https://img.cdn.aliyun.dcloud.net.cn/guide/uniapp/%E7%AC%AC1%E8%AE%B2%EF%BC%88uni-app%E4%BA%A7%E5%93%81%E4%BB%8B%E7%BB%8D%EF%BC%89-%20DCloud%E5%AE%98%E6%96%B9%E8%A7%86%E9%A2%91%E6%95%99%E7%A8%8B@20181126.mp4" placeholder="请输入视频地址,支持mp4/flv格式"/>
            <button onclick="playVideo1()">播放</button>
            <br/>
            <input id="path2" type="text" value="http://ivi.bupt.edu.cn/hls/cctv1hd.m3u8" placeholder="请输入视频地址,支持rtmp直播"/>
            <button onclick="playVideo2()">直播</button>
        </div>
        <div id="pp" class="button" onclick="ppVideo()">播放</div>
        <div class="button" onclick="fullscreenVideo()">全屏</div>
        <div id="rate" class="button" onclick="switchRate()">切换倍速(1)</div>
        <div class="button" onclick="updateVideo()">更新direction</div>
        <div class="button" onclick="createSubview()">控件上内容显示/隐藏</div>
    </body>
</html>