微信小程式:地理位置 API,圖片資訊 API

高洛峰
發布: 2017-03-03 10:39:00
原創
1746 人瀏覽過

wx.chooseLocation(OBJECT)

開啟地圖選擇位置
OBJECT參數說明:
[tr]參數類型必填說明[/tr]

##fail Function否介面呼叫失敗的回呼函數#completeFunction#否介面呼叫結束的回呼函數(呼叫成功、失敗都會執行)
success Function 介面調用成功的回呼函數,返回內容詳見返回參數說明。
cancel Function 當使用者取消時呼叫

#success回傳參數說明:[tr]參數說明[/tr]

name位置名稱address詳細位址latitude緯度,浮點數,範圍為-90~90,負數表示南緯#longitude經度,浮點數,範圍為-180~180,負數表示西經


wx.getImageInfo (OBJECT)

取得圖片資訊
OBJECT參數說明:[tr]參數類型必填說明[/tr]

srcString是圖片的路徑,可以是相對路徑,臨時檔案路徑,儲存文件路徑successFunction#介面呼叫成功的回呼函數failFunction否介面呼叫失敗的回呼函數completeFunction否介面呼叫結束的回呼函數(呼叫成功、失敗都會執行)

#success回傳參數說明:[tr]參數型別說明[/tr]

widthNumber圖片寬度,單位pxheightNumber圖片高度單位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 seek
 <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>
登入後複製
播放
position跳到指定位置,單位s
範例程式碼:
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
播放

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學習者快速成長!