微信小程序:地理位置 API,图片信息 API

高洛峰
发布: 2017-03-03 10:39:00
原创
1748 人浏览过

wx.chooseLocation(OBJECT)

打开地图选择位置
OBJECT参数说明:
[tr]参数类型必填说明[/tr]

success Function 接口调用成功的回调函数,返回内容详见返回参数说明。
cancel Function 用户取消时调用
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明:
[tr]参数说明[/tr]

name 位置名称
address 详细地址
latitude 纬度,浮点数,范围为-90~90,负数表示南纬
longitude 经度,浮点数,范围为-180~180,负数表示西经


wx.getImageInfo(OBJECT)

获取图片信息
OBJECT参数说明:
[tr]参数类型必填说明[/tr]

src String 图片的路径,可以是相对路径,临时文件路径,存储文件路径
success Function 接口调用成功的回调函数
fail Function 接口调用失败的回调函数
complete Function 接口调用结束的回调函数(调用成功、失败都会执行)

success返回参数说明:
[tr]参数类型说明[/tr]

width Number 图片宽度,单位px
height Number 图片高度 单位px

示例代码:

wx.getImageInfo({
    src: 'images/a.jpg',
    success: function(res) {
        console.log(res.width) console.log(res.height)
    }
}) wx.chooseImage({
    success: function(res) {
        wx.getImageInfo({
            src: res.tempFilePaths[0],
            success: function(res) {
                console.log(res.width) console.log(res.height)
            }
        })
    }
})
登录后复制


wx.createAudioContext(audioId)

创建并返回 audio 上下文 audioContext 对象
audioContext

audioContext 通过 audioId 跟一个 audio 组件绑定,通过它可以操作一个 audio 组件。
audioContext对象的方法列表:
[tr]方法参数说明[/tr]

play播放
pause暂停
seekposition跳转到指定位置,单位 s

示例代码:

 <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);"></span>
  <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);">播放</span>
  <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);">暂停</span>
  <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);">设置当前播放时间为14秒</span>
  <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);">回到开头</span>
登录后复制


audio.jsPage({
    onReady: function(e) { // 使用 wx.createAudioContext 获取 audio 上下文 
        context this.audioCtx = wx.createAudioContext(&#39;myAudio&#39;)
    },
    data: {
        src: &#39;http://ws.stream.qqmusic.qq.com/M500001VfvsJ21xFqb.mp3?guid=ffffffff82def4af4b12b3cd9337d5e7&uin=346897220&vkey=6292F51E1E384E06DCBDC9AB7C49FD713D632D313AC4858BACB8DDD29067D3C601481D36E62053BF8DFEAF74C0A5CCFADD6471160CAF3E6A&fromtag=46&#39;,
    },
    audioPlay: function() {
        this.audioCtx.play()
    },
    audioPause: function() {
        this.audioCtx.pause()
    },
    audio14: function() {
        this.audioCtx.seek(14)
    },
    audioStart: function() {
        this.audioCtx.seek(0)
    }
})
登录后复制



wx.createVideoContext(videoId)

创建并返回 video 上下文 videoContext 对象
videoContext

videoContext 通过 videoId 跟一个 video 组件绑定,通过它可以操作一个 video 组件。
videoContext对象的方法列表:
[tr]方法参数说明[/tr]

play播放
pause暂停
seekposition跳转到指定位置,单位 s
sendDanmudanmu发送弹幕,danmu 包含两个属性 text, color。

示例代码:

<span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);"> 
  <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);"/>  
  <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);"> 
    <span class="hljs-tag" style="box-sizing: border-box; -webkit-tap-highlight-color: transparent; -webkit-font-smoothing: antialiased; font-size: inherit; color: rgb(200, 40, 41);"/>
  </span>
</span>
登录后复制


更多微信小程序:地理位置 API,图片信息 API相关文章请关注PHP中文网!

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!