appcelerator 中的视频播放器无法播放

Video Player in appcelerator not playing

我试图在从另一个控制器获取 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();
});

你能在浏览器上打开那个视频吗? 因为当我试图从 DashboardController.js 文件打开那个 url 时,它显示 404 错误。

我认为你在 json 对象中设置了两次 url。

{
    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"
}

删除其中一个再试一次。