AnimationVideo.play

解释:播放
Web 态说明:详见 animation-video 组件 Web 态说明。

# 方法参数

# 示例

扫码体验
重新加载
请使用百度APP扫码

# 图片示例

# 代码示例

    <view class="wrap">
        <view class="card-area">
            <view class="video-area">
                <animation-video
                    id="myAnimationVideo"
                    path="{{path}}"
                    loop="{{loop}}"
                    resource-width="800"
                    resource-height="400"
                    canvas-style="width:200px;height:200px"
                    autoplay="{{autoplay}}"
                    bindstarted="started"
                    bindended="ended"
                ></animation-video>
            </view>
            <button class="btn" type="primary" bindtap="changeStatus">{{status}}动画</button>
        </view>
    </view>
    
    Page({
        data: {
            loop: true,
            path: 'https://efe-h2.cdn.bcebos.com/ceug/resource/res/2020-1/1577964961344/003e2f0dcd81.mp4',
            status: '暂停',
            autoplay: true
        },
        onLoad() {
            // 创建动画组件实例
            this.myAnimationVideo = swan.createAnimationVideo('myAnimationVideo');
        },
        changeStatus() {
            let action = this.data.status;
            let status = action  === '暂停' ? '播放' : '暂停';
            status === '暂停' ? this.myAnimationVideo.play() : this.myAnimationVideo.pause();
            this.setData({status});
        },
        started(e) {
            console.log('animationVideo', e.type);
        },
        ended(e) {
            console.log('animationVideo', e.type);
        }
    });
    
    .video-area {
        height: 2.18rem;
        background: #343434;
        display: flex;
        align-items: center;
        justify-content: center;
    }