zhao_js
2024-10-21 c5f1a3589bd8924c11dbe01aabe1e760a14df3e4
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
<template>
    <view class="root">
        <video ref="myVideos" id="myVideo" :src="this.src" @play="playIng" :loop="true" :enable-progress-gesture="false"
         :page-gesture="false" :initial-time="15" :controls="false" :show-fullscreen-btn="false" :show-center-play-btn="false"
         :style="boxStyle" @tap="pause()"></video>
        <!-- <image
            class="videoImg"
            :src="this.src+'?x-oss-process=video/snapshot,t_1,m_fast'" resize="contain"
            :style="boxStyle"
        ></image> -->
    </view>
</template>
 
<script>
    export default {
        watch: {
            state: {
                handler(newValue, oldValue) {
                    // console.log(newValue)-;
                    setTimeout(() => {
                        var createVideoContext = uni.createVideoContext('myVideo', this);
                        switch (newValue) {
                            case 'play':
                                createVideoContext.seek(0);
                                createVideoContext.play();
                                break;
                            case 'continue':
                                createVideoContext.play();
                                break;
                            case 'pause':
                                createVideoContext.pause();
                                break;
                            case 'stop':
                                createVideoContext.seek(0);
                                createVideoContext.pause();
                                break;
                            default:
                                break;
                        }
                    })
                },
                immediate: true
            },
            current:{
                handler(n){
                    if (n != this.sign) {
                        setTimeout(()=>{
                            this.state = 'stop'
                        },500)
                    } else {
                        setTimeout(()=>{
                            this.state = 'play'
                        },500 )
                    }
                }
            }
        },
        created() {
            console.log(this.current);
            // this.current = this.sign
            this.state = 'pause'
            setTimeout(()=>{
                this.state = 'play'
            },500)
        },
        destroyed() {},
        props: {
            state: {
                default: false
            },
            src: {
                default: false
            },
            boxStyle: {
                default: {}
            },
            current: {
                default: 0
            },
            sign: {
                default: 0
            }
        },
 
        methods: {}
    }
</script>
 
<style>
    .root {
        background-color: #000000;
        position: relative;
    }
 
    .videoImg {
        position: absolute;
        top: 0;
        left: 0;
    }
</style>