gpt4 book ai didi

audio - Titanium:点击表中的一行时尝试播放声音时出错?

转载 作者:行者123 更新时间:2023-12-03 02:25:37 24 4
gpt4 key购买 nike

我正在制作一个相当简单的应用程序,它显示一个表格,其中每行包含一个英语单词和相应的波兰语单词。当按下一行时,它应播放所表达单词的声音片段。但是,即使我尝试使用Google提供的所有功能对其进行故障排除,也无法使其正常工作。如果有人可以指出缺陷,将不胜感激。

var win = Titanium.UI.currentWindow;
var data =[];

var CustomData = [
{ file:'001', english:'Do you?', polish:'Czy masz?', fav:false },
{ file:'002', english:'How long?', polish:'Jak d?ugo?', fav:false },
{ file:'003', english:'Is it?', polish:'Czy?', fav:false },
];

var section = Ti.UI.createTableViewSection();
data.push(section);

for (var i=0; i<CustomData.length; i++) {
var row = Ti.UI.createTableViewRow({layout : 'vertical', height:'auto'});

var item = Ti.UI.createLabel({
color:'#000',
text:CustomData[i].english,
font:{fontSize:12, fontWeight:'bold'},
top:3,
left:10,
right:30,
height:'auto'
});
row.add(item);

var cost = Ti.UI.createLabel({
color:'#444',
text:CustomData[i].polish,
font:{fontSize:12},
top:0,
left:15,
right:30,
bottom:5,
height:'auto'
});

row.add(cost);
row.filter = CustomData[i].english;
section.add(row);
};

var tableview = Titanium.UI.createTableView({
data:data, search:search, searchHidden:false, filterAttribute: 'filter' });

win.add(tableview);

tableview.addEventListener('click', function(e)
{
var sound = Titanium.Media.createSound();
sound.url = '../sound/' + e.rowData.file + '.mp3';
sound.play();

if (e.rowData.test)
{
var win = Titanium.UI.createWindow({
url:e.rowData.test,
title:e.rowData.title
});
Titanium.UI.currentTab.open(win,{animated:true});
}
});

最佳答案

只是在黑暗中拍摄,但您确定可以在创建声音对象后设置URL吗?你有没有尝试过:

Titanium.Media.createSound({url:'../sound/' + e.rowData.file + '.mp3'});

除此之外,您确定相对URL是从您认为的地方进行评估的吗?也许可以尝试使用绝对URL进行尝试。

关于audio - Titanium:点击表中的一行时尝试播放声音时出错?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5601789/

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