У меня есть такой метод в моем приложении, но это не использует jQuery:
/* Get the TOP position of a given element. */
function getPositionTop(element){
var offset = 0;
while(element) {
offset += element["offsetTop"];
element = element.offsetParent;
}
return offset;
}
/* Is a given element is visible or not? */
function isElementVisible(eltId) {
var elt = document.getElementById(eltId);
if (!elt) {
// Element not found.
return false;
}
// Get the top and bottom position of the given element.
var posTop = getPositionTop(elt);
var posBottom = posTop + elt.offsetHeight;
// Get the top and bottom position of the *visible* part of the window.
var visibleTop = document.body.scrollTop;
var visibleBottom = visibleTop + document.documentElement.offsetHeight;
return ((posBottom >= visibleTop) && (posTop <= visibleBottom));
}
Редактирование: Этот метод работает хорошо на Т.Е. (по крайней мере, версия 6). Прочитайте комментарии для совместимости с И следующие
Вы также можете попробовать AVAudioPlayer Framework служебной программы.
Используйте afconvert в Терминале, чтобы преобразовать ваш MP3 в .caf. man afconvert расскажет вам больше.
Затем
NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: name ofType: @"caf"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer *player = [super initWithContentsOfURL: fileURL error: nil];
[fileURL release];
[player play];
Можно посмотреть: http://iphoneincubator.com/blog/audio-video/simple-way-to-play-mp3-audio-files и http://cocoawithlove.com/2008/09/streaming-and-playing-live-mp3-stream.html ?