search
HomeWeChat AppletMini Program DevelopmentExample analysis of media components of WeChat mini program

Example analysis of media components of WeChat mini program

Feb 08, 2018 am 10:53 AM
Case AnalysisAppletscomponents

This article mainly introduces relevant information about the media components of WeChat mini programs, including videos, music, and pictures. It has certain reference value. Interested friends can refer to it. I hope it can help everyone.

Let’s take a look at the renderings first:

 

1. Picture Image


##

<!-- 
 scaleToFill:不保持纵横比缩放图片,使图片的宽高完全拉伸至填满 image 元素 
 widthFix:宽度不变,高度自动变化,保持原图宽高比不变 
 aspectFill:保持纵横比缩放图片,只保证图片的短边能完全显示出来。 
    也就是说,图片通常只在水平或垂直方向是完整的,另一个方向将会发生截取。 
 aspectFit: 保持纵横比缩放图片,使图片的长边能完全显示出来。也就是说,可以完整地将图片显示出来。 
 
 --> 
 
<image style=&#39;width: 100%; height:150px&#39; src=&#39;../img/models.jpg&#39; mode=&#39;scaleToFill&#39;></image> 
<image style=&#39;width: 200px; height:200px&#39; src=&#39;../img/models.jpg&#39; mode=&#39;widthFix&#39;></image> 
<image style=&#39;width: 200px; height:100px&#39; src=&#39;../img/models.jpg&#39; mode=&#39;aspectFill&#39;></image> 
<image style=&#39;width: 200px; height:100px&#39; src=&#39;../img/models.jpg&#39; mode=&#39;aspectFit&#39;></image>

Picture display, different display modes can be set according to the mode attribute.


2. Music playback audio



<!-- 
 简单的实现音乐播放 
 src:播放音频的资源地址 
 poster:封面图片地址 
 controls:是否显示默认控件 
 name:歌曲名称 
 author:歌曲作者 
 --> 
<audio src="{{url}}" poster="{{poster}}" controls="true" author="{{author}}" name="{{name}}"></audio>

3. Video playback video



<!-- 
 播放视频 
 src:视频资源链接 
 danmu-list:弹幕列表 
 danmu-btn:是否显示弹幕按钮 
 enable-danmu:是否展示弹幕,只在初始化有效 
 loop:是否循环播放 
 muted 是否静音播放 
 --> 
 
<video id=&#39;videocontext&#39; src="{{src}}" danmu-btn=&#39;true&#39; danmu-list=&#39;{{danmuList}}&#39; enable-danmu=&#39;true&#39; loop=&#39;false&#39; muted=&#39;false&#39;></video> 
<input class=&#39;text_danmu&#39; bindblur=&#39;bindInputBlur&#39; type=&#39;text&#39;></input> 
<button bindtap=&#39;bindSendDanmu&#39; type=&#39;primary&#39;>提交弹幕</button>

The control usage is similar to that of H5, with less code and powerful functions;


Related recommendations:


JS preloading video and audio /Share tips for getting screenshots from videos

How to use video and audio tags and progress bars in H5

Summary of methods for inserting videos into HTML web pages

The above is the detailed content of Example analysis of media components of WeChat mini program. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools