I am new to ionic framework please help me..
I am using iframe to embed youtube video and also using ?autopaly=1 to autoplay the video, its working in browser but not in android.
Got embedded youtube videos to work in Ionic defining the URL in controllers.js with $scope then creating a filter in app.js.
Code for controllers.js
.controller('FooCtrl', function($scope,$stateParams) {
$scope.videoSet = [
[
{ url: 'https://www.youtube.com/embed/oHg5SJYRHA0?rel=0&autoplay=1', t: '3:33'}
]
];
$scope.videoId = $stateParams.videoId;
})
Code for app.js
.filter('trustAsResourceUrl', ['$sce', function($sce) {
return function(val) {
return $sce.trustAsResourceUrl(val);
};
}])
Code for foo.html template
<ion-view view-title="Youtube Videos">
<ion-content ng-repeat="video in videoSet[videoId]">
<ion-list>
<div class="card">
<ion-item>
<iframe src="{{video.url | trustAsResourceUrl}}" frameborder="0" width="560" height="315"></iframe>
</ion-item>
</div>
</ion-list>
</ion-content>
</ion-view>
Hope this works for you