gpt4 book ai didi

iOS - Titanium Appcelerator,创建带预览的视频库

转载 作者:行者123 更新时间:2023-11-29 12:39:22 25 4
gpt4 key购买 nike

我想做的是用 n 视频创建一个视频库。在ScrollView中添加n View ,每个视频一个 View ,并在每个 View 中加载相应视频的图片(等待每个视频的加载)。在按住 (TouchStart) View 时,将在 View 中加载视频的其他图像(以便直接在迷你 View 中显示视频预览),直到松开手指 (touchEnd)。

到目前为止,没问题,我的问题是我想通过在迷你 View 上按 (CLICK) 来全屏显示视频!

enter image description here

这是我的代码

//****************************************************************************************************************

var arr_vidplayer_VARIE = [];
var arr_vidplayer_VARIE_duration = [];
var arr_vidplayer_VARIE_cont = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
var timer_VARIE = null;

var num_video_VARIE = 37;
var arr_view_VARIE = [];
var left_VARIE= -200;
var top_VARIE = -100;
var actual_video_VARIE = 1;

//****************************************************************************************************************

var win = Ti.UI.createWindow({
backgroundColor : 'white',
fullscreen : true
});


var scroll_VARIE = Ti.UI.createScrollView({
width : 1024,
height : 700,
top : 0
});

scroll_VARIE.addEventListener("scroll",function(e){
clearInterval(timer_VARIE);
});

//****************************************************************************************************************

function START_VARIE(){

if(actual_video_VARIE <= num_video_VARIE){

if((actual_video_VARIE-1) %4 == 0){
top_VARIE+=150;
left_VARIE=45;
}else{
left_VARIE+=245;
}

CREATE_VIDEO_VARIE(top_VARIE,left_VARIE,actual_video_VARIE);

}
}

function CREATE_VIDEO_VARIE(top,left,id){

var myurl = "/video/"+id+".mov";

var video = Titanium.Media.createVideoPlayer({
url : myurl,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
fullscreen : true,
id : parseInt(id),
autoplay : true,
//zIndex : 9999999999999
//visible : false
});

video.addEventListener("loadstate",function(e){
END_LOAD_VARIE(e.source.id,e.loadState);
});

arr_vidplayer_VARIE.push(video);

var view_video = Ti.UI.createView({
width : 200,
height : 120,
left : left,
top : top,
id : parseInt(id),
borderColor : "black"
});

view_video.addEventListener("touchstart",function(e){

var i = parseInt(e.source.id) - 1;

timer_VARIE = setInterval(function(e){

if(arr_vidplayer_VARIE_cont[i] < arr_vidplayer_VARIE_duration[i]){

arr_vidplayer_VARIE_cont[i]++;
var img = arr_vidplayer_VARIE[i].thumbnailImageAtTime(arr_vidplayer_VARIE_cont[i],Titanium.Media.VIDEO_TIME_OPTION_EXACT);
if(img == "[object TiBlob]"){
try{
arr_view_VARIE[i].children[0].image = arr_vidplayer_VARIE[i].thumbnailImageAtTime(arr_vidplayer_VARIE_cont[i],Titanium.Media.VIDEO_TIME_OPTION_EXACT);
}catch(e){
clearInterval(timer_VARIE);
}
}

}else{
arr_vidplayer_VARIE_cont[i] = 0;
}

},200);

});

view_video.addEventListener("touchend",function(e){
clearInterval(timer_VARIE);
});

view_video.addEventListener("click",function(e){

arr_vidplayer_VARIE[parseInt(e.source.id)-1].play();
Ti.API.info("play "+e.source.id);

});

var image_video = Ti.UI.createImageView({
width : 200,
height : 120,
left : 0,
top : 0,
id : parseInt(id),
});


var activity = Ti.UI.createActivityIndicator({
style : Ti.UI.iPhone.ActivityIndicatorStyle.DARK
});

view_video.add(image_video);
view_video.add(activity);
//win.add(video);
activity.show();

arr_view_VARIE.push(view_video);
scroll_VARIE.add(view_video);

}

function END_LOAD_VARIE(id,state){

if(parseInt(state) == 3){
arr_view_VARIE[id-1].children[1].hide();
arr_view_VARIE[id-1].children[0].image = arr_vidplayer_VARIE[id-1].thumbnailImageAtTime(1,Titanium.Media.VIDEO_TIME_OPTION_EXACT);
arr_vidplayer_VARIE_duration.push(parseInt(arr_vidplayer_VARIE[id-1].getDuration()/1000));
actual_video_VARIE++;
START_VARIE();
}

}


//****************************************************************************************************************

START_VARIE();

win.add(scroll_VARIE);
win.open();

//****************************************************************************************************************

最佳答案

Appcelerator 文档声明 iOS 上的全屏属性在电影播放器​​的 View 可见之前无效。尝试:

var video = Titanium.Media.createVideoPlayer({
url : myurl,
mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FILL,
fullscreen : false,
id : parseInt(id),
autoplay : true
});

view_video.addEventListener("click",function(e){
view_video.setFullscreen(true);
arr_vidplayer_VARIE[parseInt(e.source.id)-1].play();
Ti.API.info("play "+e.source.id);
});

关于iOS - Titanium Appcelerator,创建带预览的视频库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25414274/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com