Hi there,
i have changed the function like below because app was waiting to much to open everytime. With this code:
i am checking the file if exists or not, if doesn't exists i am downloading it to the Application Directory and play from there, so i think it is more faster.
i am using this module from MarketPlace;
https://marketplace.appcelerator.com/apps/907?351828443#overview
i am making something wrong again i think, while i am chechkin file exists or not , if file doesn't exists i am downloading but after that the sound doesn't start to play?
how can i clean the downloaded files? i am cleaning the project files but they are not cleaning :(
i am really curios about something, can compare the size ot the files? if the remote file is bigger then the local file, i must to download it again
How can i find my ApplicationDataDirectory from my computer? i am using lion and i can't find my user/library/ApplicationSupport Directory?
Thanks for reading
function loopMessageSound() { messageSound = Ti.Media.createSound({ preload : true}); var _callBack_DownloadOneFileFinished = function(download_result) { Ti.API.info("Finished Downloading:" + download_result.path); }; var file_exists = Ti.Filesystem.getFile(Ti.Filesystem.applicationDataDirectory,songs[index].mp3); Ti.API.info("File Exists:"+file_exists.exists()); if (file_exists.exists() === false) { Ti.API.info("File Doesn't Exists and start Download"); utility.downloadOneFile("http://www.xxx.com"+songs[index].mp3, Titanium.Filesystem.applicationDataDirectory + songs[index].mp3, messageSound.play()); }else{ Ti.API.info("File Exists and Don't DOWNLOAD'.") } messageSound.url = Titanium.Filesystem.applicationDataDirectory + songs[index].mp3; messageSound.desc = index+1+". "+songs[index].baslik; playing.text = messageSound.desc; playing.opacity = 0; playing.animate({ curve: Ti.UI.iOS.ANIMATION_CURVE_EASE_IN_OUT, opacity: 1, duration: 1500 }); messageSound.addEventListener('complete', function(e) { index ++; if (index < songs.length){ loopMessageSound(); } else { Ti.API.info("Song Loop Complete"); index = 0; loopMessageSound(); } }); messageSound.play(); }
2 Answers
Accepted Answer
Hello, Instead of using
if(file_exists.exists() === false)simply use
if(!file_exists.exists())
If you need to delete simulator memory then click on close button on simulator , so that your app goes in background , now delete application on simulator by long click on app icon and then selecting delete from alert dialog., this will completely remove application memory from your system . You need to download some software than you can see user/library/ApplicationSupport Directory folder , may be its hidden by default on your mac.
you can check the timestamp on the file and only download if there is a newer file? Are you writting the code on the server?
Your Answer
Think you can help? Login to answer this question!