>  기사  >  위챗 애플릿  >  WeChat 미니 프로그램: Geolocation API, 이미지 정보 API

WeChat 미니 프로그램: Geolocation API, 이미지 정보 API

高洛峰
高洛峰원래의
2017-03-03 10:39:001753검색

wx.chooseLocation(OBJECT)

지도를 열고 위치를 선택하세요
OBJECT 매개변수 설명:
[tr] 매개변수 유형의 필수 설명[/tr]

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

성공하면 매개변수 설명이 반환됩니다.
[tr]매개변수 설명[/tr]

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


wx.getImageInfo(OBJECT)

이미지 정보 가져오기
OBJECT 매개변수 설명:
[ tr]매개변수 유형 필수 설명[/tr]

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

성공하면 매개변수 설명이 반환됩니다.
[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)

생성 및 return audio Context audioContext 객체
audioContext

audioContext는 audioId를 통해 오디오 구성 요소에 바인딩되며 이를 통해 오디오 구성 요소가 작동될 수 있습니다.
audioContext 객체의 메소드 목록:
[tr]메소드 매개변수 설명[/tr]

play 播放
pause 暂停
seek position 跳转到指定位置,单位 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)

비디오 컨텍스트 videoContext 객체 생성 및 반환
videoContext

videoContext는 videoId와 비디오 구성 요소 바인딩. 이를 통해 비디오 구성 요소를 조작할 수 있습니다.
videoContext 객체의 메소드 목록:
[tr]메소드 매개변수 설명[/tr]

play 播放
pause 暂停
seek position 跳转到指定位置,单位 s
sendDanmu danmu 发送弹幕,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>


더 많은 WeChat 미니 프로그램: 지리적 위치 API, 사진 정보 API 관련 기사를 보려면 PHP 중국어 웹사이트를 주목하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.