我在視頻源的地圖框中添加了一個圖層。下面是腳本:如何在Mapbox中獲取視頻的當前時間?
map.addSource("storm-source", {
type: "video",
urls: [
"C:/flood.mp4" // path to our video
],
coordinates: [
[ -79.1680785004, 34.7195831793 ],
[ -78.8680220490, 34.7195831793 ],
[ -78.8680220490, 34.4762734894 ],
[ -79.1680785004, 34.4762734894 ]
] // the coordinates to which your data is clipped:
});
// add this layer to the map
map.addLayer({
"backgroung": 'transparent',
"type": 'raster',
"id": "storm-layer",
"source": "storm-source",
paint: {
"raster-opacity": 1
}
},
'hillshade_shadow_faint'); // "after" our lowest hillshade layer
現在,當視頻flood.mp4
的播放位置發生了變化,我想顯示的視頻在幾秒鐘內的當前位置。 Mapbox的腳本是什麼?我知道兩條語句var mySource = map.getSource("storm-source");
和mySource.getVideo().currentTime
可以給出特定時刻的當前視頻時間,但只要視頻正在運行,我想要始終/連續顯示當前時間。
謝謝。其實。我有一個「開始」按鈕,當我點擊按鈕時,視頻應該播放。但是,我試過並顯示錯誤:index.html:188 Uncaught TypeError:mySource.addEventListener不是HTMLButtonElement中的函數 。(index.html:188) –
Kayes
此外,我刪除了「開始」按鈕,並嘗試但得到相同的錯誤:mySource.addEventListener不是一個函數。 – Kayes
沒有看到你的用例在轉載。我只是在這裏猜測 – iH8