2016-03-08 90 views
0

当我在Android上使用纯html5视频/音频时,我有我的用户在启动时单击按钮。在点击处理程序中,我kickstart所有媒体:自动启动Android上的视频视频/声音可能吗?

$('.viewaud').each(function(i,el){ 
       el.load(); 
       el.play(); 
       el.pause(); 
      }) 

之后,我可以以编程方式启动视频/声音,无需用户点击。 视频中可能有类似的东西吗?

回答

0

是的,你可以做一些类似的视频。

HTML模板:

<videogular vg-player-ready="vm.onPlayerReady($API)"> 
    <!-- other components --> 
</videogular> 
<button type="button" ng-click="vm.onClickStart()">Start</button> 

JS控制器:

angular.module("myApp").controller("MainCtrl", 
    function ($sce) { 
     this.onPlayerReady = function (API) { 
      this.API = API; 
     }; 

     this.onClickStart = function (event) { 
      this.API.play(); 
      this.API.pause(); 
     }; 

     // More code... 
    } 
); 
+0

谢谢!工作正常,但只适用于当前玩家。我能以某种方式循环播放所有视图中的所有玩家吗? –

+0

检查这个答案,你可以将所有的视频APIs保存在一个数组中,并通过它们循环http://stackoverflow.com/questions/31827732/stop-other-video-that-is-playing-in-background-on-play- the-new-one – elecash

+0

正如我理解链接中的解决方案一样,可以在一个控制器/视图中了解所有的API。但我想遍历所有控制器/视图中的所有API,或者对所有视频使用相同的API。可能吗? –