
使用HTML5設計網頁只要使用VIDEO標籤即可完成,大大減少以前引用外掛的網頁語法,使用內建瀏覽器播放影片,在iPhone上往往無法自動播放網頁影片,我們利用一些小技巧示範,您可以使用iPhone或iPad打開我們這個網頁,看看影片是否會自動播放。
HTML5網頁影片如何設計在iPhone上自動播放
有許多手機網頁會放置背景影片,看起來整個網站更加生動活潑。但是有許多手機採用IOS系統,基於APPLE政策,影片需要手機持有人按下播放鈕才會開始動作,這樣網頁設計師想要表現的視覺將大大扣分,我使用IOS 10裝置測試,利用canvas-video-player修改,增加iPad、iPhone、iPod判斷,使用iPhone手機看本網頁會自動播放影片了。

圖片尺寸640*480pixel
因為在github.com上的canvas-video-player.js不斷被更新,有可能修改行數跟本篇教學有差異,需要網友自行比對修改處。
- 找出下面程式語法:
this.options = { framesPerSecond: 25, hideVideo: true, autoplay: false, audio: false, timelineSelector: false, resetOnLastFrame: true, loop: false };
修改成this.options = { framesPerSecond: 25, hideVideo: true, autoplay: false, makeLoop: false, pauseOnClick: true, audio: false, timelineSelector: false, resetOnLastFrame: true, loop: false };
- 找出下面程式語法:
this.canvas.addEventListener('click', cvpHandlers.canvasClickHandler = function() { self.playPause(); });
修改成if(this.options.pauseOnClick === true){ this.canvas.addEventListener('click', cvpHandlers.canvasClickHandler = function() { self.playPause(); }); }
- 找出下面程式語法:
if (this.video.currentTime >= this.video.duration) { this.playing = false; if (this.options.resetOnLastFrame === true) { this.video.currentTime = 0; } if (this.options.loop === true) { this.video.currentTime = 0; this.play(); } }
修改成if (this.video.currentTime >= this.video.duration) { if(this.options.makeLoop === false){ this.playing = false; } if (this.options.resetOnLastFrame === true) { this.video.currentTime = 0; } if (this.options.loop === true) { this.video.currentTime = 0; this.play(); } }
- 網頁中宣告以下JavaScript指令:
var canvasVideo = new CanvasVideoPlayer({ videoSelector: '原始HTML5影片CLASS名稱', canvasSelector: '要使用canvas的區塊CLASS名稱', timelineSelector: false, autoplay: true, makeLoop: true, pauseOnClick: false, audio: false });
- publisher:
- 文網股份有限公司
-
圖片尺寸240*240pixel
CONTACT INFORMATION
其他新聞
-
前端網頁設計動畫套件anime easing介紹與範例
Published on 2025-02-10 00:00:00 -
NPU是甚麼?詳細解說CPU、GPU、NPU、TPU!
Published on 2024-10-31 14:00:00 -
環保公司網頁設計案例:樺欣環保工程有限公司官網建置
Published on 2024-09-19 18:00:00 -
選擇網頁設計公司依據地圖評價準確嗎?
Published on 2024-09-15 12:00:00 -
甚麼是ARM伺服器?
Published on 2024-06-22 00:00:00 -
自行架設網站的優缺點分析
Published on 2024-03-10 18:00:00 -
房地產網頁設計案例:詠騰工業不動產官網架設
Published on 2023-12-31 10:50:00 -
無障礙網站設計與無障礙標章檢測等級
Published on 2023-10-29 14:10:00 -
如何挑選出穩健的網頁設計公司
Published on 2023-09-16 14:30:00 -
網頁設計報價計算方式有哪些?
Published on 2023-08-11 12:00:00 -
新竹山溪地高爾夫球場網頁設計規劃介紹
Published on 2023-04-27 12:20:00 -
台灣質譜學會活動報名系統網站設計
Published on 2023-04-15 08:00:00