歡迎光(guāng)臨,新啓科(kē)技(jì)

Chrome浏覽器(qì)iframe中使用(yò©¥≠¶ng)Flash是(shì)否自(zì)動播放(fàng)?

2016/11/15 16:00:23

 HTML頁面中播放(fàng)Flash視(shì)✔©頻(pín)的(de)時(shí)候,遇到(dào)了(le)一(∑λyī)個(gè)小(xiǎo)問(wèn)題,那(n' à)就(jiù)是(shì)如(rú)果Flash播放(fàng)器(×®σ✘qì)的(de)寬和(hé)高(gāo)不(bù≠§≤‍)合适,那(nà)麽Chrome就(jiù)會(₽ε♦huì)攔截播放(fàng)器(qì)的(de)自(zì)動播放(fàng£♥)

然後必須要(yào)點擊一(yī)下(xià)λπ♥♠播放(fàng)按鈕,才能(néng)繼續播放(fàng)。π♣

給出了(le)下(xià)面幾個(gè)解決方法✘₹≤♦:

1、使用(yòng)ExternalInterface

2、初始化(huà)播放(fàng)器(qì)尺寸大(dà)于398x29↓≤↓∏8,然後使用(yòng)transform: scale()。


Google 到(dào)了(le) Chrλλ±♣ome 官方論談的(de)一(yī)篇帖子(zǐ)。帖子(zǐ)把 ↕δChromium 的(de)源碼都(dōu)給扒出來(lá<☆‌i)了(le),最終給出了(le)一(yī)個€∑'(gè)解決辦法:

1、跨站(zhàn)(Cross-origin)的(de) fla​&sh 的(de)寬度至少(shǎo)是(shì) 39±®₽8,高(gāo)度至少(shǎo)是(shì) 298,否則會( ♠Ωhuì)被認為(wèi)是(shì)不(bù)重要 ₹♦≠(yào)的(de) flash
2、flash 內(nèi)容的(de)寬度比"↓≈為(wèi) 16:9 的(de) flash 會(huì)被當作↔••(zuò)重要(yào)的(de),因此可¥×↓(kě)以自(zì)動播放(fàng)。


相(xiàng)關的(de)源碼如(rú)下(xià):

// Content below this‌§ size in height and width®§ is considered "tiny">÷.
// Tiny content is never peripheral, as←"÷ tiny plugins often serve a £✔critical
// purpose, and the user often cann ÷​ot find and click to unthrottle i₩← t.
const int kTinyContentSize•‌☆≤ = 5;

// Cross-origin content must h←← ave a width and height both exceeding ≈☆these
// minimums to be considered "large", a€±nd thus not peripheral.≤β
const int kLargeContΩ÷≈entMinWidth = 398;
const int kLargeContentMinHeφ↑ight = 298;

// Mark some 16:9 aspect rat≥✘ Ωio content as essential (not • €peripheral). This is to
// mark as "large" some medium size‌₩£✔d video content that meets a minimum ar₹↓ea
// requirement, even if it is below th©>★☆e max width/height abov©∏∏≈e.
const double kEssentialVideoA'∏γspectRatio = 16.0 / 9.0;
const double kAspectRatioEα₩'psilon = 0.01;

const int kEssentialVid'₩eoMinimumArea = 120000;