2013-09-07 28 views
5

How can I autoplay a video using the new embed code style for Youtube?Autoplay với <iframe> You Tube video -? Autoplay = 1 không làm việc

Mã của tôi theo các hướng dẫn và không hoạt động. Tôi cũng đã xem xét trợ giúp của YouTube và họ nói điều tương tự - không làm việc cho tôi.

<html><body> 
<iframe width="640" height="385" src="//www.youtube.com/embed/0319ZgKMLzw?autoplay" frameborder="0" allowfullscreen></iframe></body> 
</html> 

Xem nó không tự động phát here, mã có trong firebug.

Trả lời

0

cố gắng thêm = 1 sau "autoplay" trên mã của bạn

2

Chỉnh sửa mã nhúng của bạn đến và đi thêm "http: //" "autoplay = 1?". Đây là mã làm việc cho bạn ...

<iframe width="640" height="385" src="http://www.youtube.com/embed/0319ZgKMLzw?autoplay=1"> </iframe>  
0

hãy thử điều này. Nó làm việc cho tôi.

private class AutoPlayVideoWebViewClient extends WebViewClient { 

    @Override 
    public void onPageFinished(WebView view, String url) { 
     super.onPageFinished(view, url); 
     // mimic onClick() event on the center of the WebView 
     long delta = 100; 
     long downTime = SystemClock.uptimeMillis(); 
     float x = view.getLeft() + (view.getWidth()/2); 
     float y = view.getTop() + (view.getHeight()/2); 

     MotionEvent tapDownEvent = MotionEvent.obtain(downTime, downTime + delta, MotionEvent.ACTION_DOWN, x, y, 0); 
     tapDownEvent.setSource(InputDevice.SOURCE_CLASS_POINTER); 
     MotionEvent tapUpEvent = MotionEvent.obtain(downTime, downTime + delta + 2, MotionEvent.ACTION_UP, x, y, 0); 
     tapUpEvent.setSource(InputDevice.SOURCE_CLASS_POINTER); 

     view.dispatchTouchEvent(tapDownEvent); 
     view.dispatchTouchEvent(tapUpEvent); 
    } 
} 

Somewhere,

myWebView.setWebViewClient(new AutoPlayVideoWebViewClient()); 
Các vấn đề liên quan