【问题标题】:Video Player in appcelerator not playingappcelerator中的视频播放器不播放
【发布时间】: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();
});

【问题讨论】:

    标签: appcelerator video-player


    【解决方案1】:

    你能在浏览器上打开那个视频吗? 因为当我尝试从 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"
    }
    

    删除其中一个再试一次。

    【讨论】:

    • 是的,我想通了,并制作了视频播放...感谢您的帮助 mitul! :)
    猜你喜欢
    • 1970-01-01
    • 2014-06-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多