【发布时间】:2017-07-10 14:54:19
【问题描述】:
在从不同的控制器获取 url 作为参数后,我试图在 appcelerator 中自动播放视频。但是视频没有播放。 这是 VideoPalyerController.xml 文件:
<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>
这是 VideoPlayerController.js 文件:
var args = $.args;
Ti.API.trace("VideoPlayerController :",args.url);
//titleLabel = args.info;
$.videoPlayer.url = args.url;
这是我将参数发送到 VideoPlayerController.js 文件的 DashboardController.js:
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();
});
【问题讨论】: