I am trying to autoplay a video in appcelerator after getting the url from a different controller as an argument. But the video isn't playing. Here is the VideoPalyerController.xml file :
<Alloy>
<View class="container" >
<View class="videoPlayerView" >
<VideoPlayer class = "videoPlayerClass" id = "videoPlayer"></VideoPlayer>
</View>
<View class="videoInfoView" layout="vertical" backgroundColor="white">
<Label class="titleLabel" backgroundColor="gray"></Label>
<View class="dateUrlView" layout="horizontal"></View>
<Label class="dateLabel" backgroundColor="lightgray"></Label>
<Label class = "urlLabel"></Label>
</View>
<!-- <View class = "buttonview">
<Button class="backButton"></Button>
</View> -->
</View>
</Alloy>
Here is the VideoPlayerController.js file :
var args = $.args;
Ti.API.trace("VideoPlayerController :",args.url);
//titleLabel = args.info;
$.videoPlayer.url = args.url;
Here is the DashboardController.js from where I am sending the arguments to VideoPlayerController.js file :
var args = $.args;
var sections = [];
//JSON to populate the listview
var videoInfo = [{
pic : "/Images/playButton.png",
info : "This in the the title for the first video.",
date : "03/07/2017",
url : "https://youtu.be/zkOSR0ZRb9khttps://youtu.be/zkOSR0ZRb9k"
}, {
pic : "/Images/playButton.png",
info : "This in the the title for the second video.",
date : "03/07/2017",
url : "https://youtu.be/zkOSR0ZRb9khttps://youtu.be/zkOSR0ZRb9k"
}, {
pic : "/Images/playButton.png",
info : "This in the the title for the third video.",
date : "03/07/2017",
url : "https://youtu.be/zkOSR0ZRb9khttps://youtu.be/zkOSR0ZRb9k"
}];
function populateListView() {
Ti.API.trace("[DashboardController.js >> populateListView() >>]");
if (!_.isEmpty(videoInfo)) {
for (var i = 0; i < videoInfo.length; i++) {
var item = {
template : "videoTemplate",
iconId : {
image : videoInfo[i].pic
},
titleId : {
text : videoInfo[i].info
},
dateId : {
text : videoInfo[i].date
},
urlId : {
text : videoInfo[i].url
},
properties : {
backgroundColor : "transparent"
}
};
sections.push(item);
}
$.listSection.setItems(sections);
}
}
populateListView();
$.lView.addEventListener('itemclick',function(e){
Ti.API.trace("[DashboardController.js >> Function to open VideoPlayerController >>]");
var dataItem = videoInfo[e.itemIndex];//$.listSection.getItemAt(e.itemIndex) ;
Ti.API.trace("Data Item is : ",dataItem);
var videoController = Alloy.createController('VideoPlayerController',{
"url":dataItem.url,
"title":dataItem.info,
"date":dataItem.date
}).getView();
Alloy.Globals.parent.add(videoController);
//videoController.open();
});
Are you able to open that video on browser? because when i tried to open that url from DashboardController.js file, it shows 404 error.
I think you set url twice in json object.
{
pic : "/Images/playButton.png",
info : "This in the the title for the second video.",
date : "03/07/2017",
url : "https://youtu.be/zkOSR0ZRb9khttps://youtu.be/zkOSR0ZRb9k"
}
remove one of that try again.