Показать сообщение отдельно
  #2 (permalink)  
Старый 17.03.2011, 00:05
Новичок на форуме
Отправить личное сообщение для rikitikitavi Посмотреть профиль Найти все сообщения от rikitikitavi
 
Регистрация: 16.03.2011
Сообщений: 3

Сам скрипт вот этот:
function AudioPlayer(params){
	if(params){
		this.container = params.container || null;
		this.template = params.template || null;
		this.activeFlashClass = params.activeFlashClass || null;
		this.inActiveFlashClass = params.inActiveFlashClass || null;
		this.playImgClass = params.playImgClass || null;
		this.pauseImgClass = params.pauseImgClass || null;
		this.transparent = params.transparent || null;
        this.noRepeat = params.noRepeat;
        this.noReplaceListeners = params.noReplaceListeners || null;
        this.prefix = (params.prefix || 'inviz' )+ '_';
		this.mFaviconSrc = params.favicon || null;
	}else throw('Error in AudioPlayer');
	if(!this.container || !this.template) throw('Error in AudioPlayer');
	this.template = new Template(this.template);
	this.volume = 70;
	this.init();
}


AudioPlayer.prototype.init = function(){
	var objs = this.container.cleanWhitespace().childElements();
	if(!this.noReplaceListeners) {
		for(var i=0; i < objs.length; i++){
			var toggles = objs[i].select('[name="audio_toggle"]');
			for(var k=0; k < toggles.length; k++){
				toggles[k].observe('click', this.toggle.bindAsEventListener(this, objs[i], 0, this.prefix, this.container));
				toggles[k].removeAttribute('onClick');
			}
		}
	} 
	this.status = 0;
	this.previousFile = null;
	this.previousContainer = null;
		this.previousPrefix = null;
	this.inAction = 0;
	this.defFaviconSrc = $$('link[rel=shortcut icon]')[0] ? $$('link[rel=shortcut icon]')[0].readAttribute('href') : null;

}


AudioPlayer.prototype.toggle = function(event, container, paused, prefix, parent_container){
    if(container && !this.inAction){
    if(prefix && prefix != this.prefix) {
		this.status = false; 
		this.toggle({}, this.previousContainer, 1);
	    this.container = parent_container;
	    this.prefix = prefix || 'inviz_';
	    this.init();
	    this.inAction = 0;
	    this.status = true; 
    }
	this.inAction = 1;	
	var file = container.readAttribute('file');
	if(this.previousFile == file && this.status){
  	    this.pause(container, file);
	    this.status = 0;
	} else {
	    if(this.previousFile == file){
		if(!paused) this.unpause(container, file);
		else {
            if($(this.prefix + file)) {
        		this.stop(container, file);
                $(this.prefix + file).style.display = 'block';
                this.previousFile = null;
                this.previousContainer = null;
                this.previousPrefix = null;
            } else {
                this.setPlayImage(container); //this.pause(container, file, 'rewind');
            }
        }
	    } else {
		if(this.previousFile && this.previousContainer){
		    this.stop(this.previousContainer, this.previousFile);
		    if ($(this.prefix+file) != null) $(this.previousPrefix+this.previousFile).style.display = 'block';
		}
                if ($(this.prefix+file) != null) $(this.prefix+file).style.display = 'none';
		this.play(container, file, paused);
		this.previousFile = file;
		this.previousContainer = container;
		this.previousPrefix = prefix || this.prefix;
	    }
	    this.status = !paused;
	}
	this.inAction = 0;
    }
}

AudioPlayer.prototype.play = function(container, file, paused){
	var flash_container = container.select('[name="audio_flash_container"]');
	if(!flash_container || !flash_container.length){
		throw('AudioPlayer: can not find flash container');
	}
	var URL = this.template.evaluate({
		URL	: container.readAttribute('url'),
		Time	: parseInt(container.readAttribute('time'))*1000,
		Vol	: this.volume,
		title: encodeURIComponent(container.readAttribute('title')),
	        uid	: container.readAttribute('uid'),
	});
	var file = container.readAttribute('file');		
    var p1 = '';
    var p2 = '';
    var p3 = '';//for FF2 and opera < 9.5
    var p4 = '';//remove in future
    if(paused) {
        p1 = '<param name="flashvars" value="pause=1"/>';
      //  p2 = 'flashvars="pause=1"';
    }
    if(!this.activeFlashClass || this.transparent){
      //  p3 = '<param name="wmode" value="transparent"/>';
        p4 = ' wmode="transparent"';
    }
	flash_container[0].innerHTML = '<object id="ie_flashplayer_'+file+'" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="100%" height="100%" style="margin:-2px 0 0 -2px"><param name="allowScriptAccess" value="always" /><param name="swLiveConnect" value="true" /><param name="movie" value="'+URL+'" />'+p1+'<param name="wmode" value="transparent"/><embed id="flashplayer_'+file+'" src="'+URL+'" width="100%" height="100%" style="margin:-2px 0 0 -2px" allowScriptAccess="always" swLiveConnect="true" '+p2+p4+' type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /></object>'; // Because fucking kriaking browsers can do that kind of shit(embed src), and fkriaging prototype also
	//ajax_call('perl_count_audio_listen');	
    if(paused) {
        this.setPlayImage(container);
    } else {
        this.setPauseImage(container);
    }
}
AudioPlayer.prototype.stop = function(container, file){
	var flash_container = container.select('[name="audio_flash_container"]');
	if(!flash_container || !flash_container.length){
		throw('AudioPlayer: can not find flash container');
	}
	flash_container[0].innerHTML = '';
	if(this.inActiveFlashClass){
                flash_container[0].className = this.inActiveFlashClass;
	}
	this.setPlayImage(container);
	this.status = 0;
}
AudioPlayer.prototype.pause = function(container, file, rewind){ 
	var flashplayer = this.getFlashPlayer(file);
	this.setPlayImage(container);
	flashplayer.pause();
    if(rewind) flashplayer.Rewind();
}
AudioPlayer.prototype.unpause = function(container, file){
	var flashplayer = this.getFlashPlayer(file);
	this.setPauseImage(container);
	flashplayer.resume();
}

AudioPlayer.prototype.getFlashPlayer = function(file){
	var flashplayer;
	if(Prototype.Browser.IE){
		flashplayer = $('ie_flashplayer_'+file);
	}else{
		flashplayer = $('flashplayer_'+file);
	}	
	if(!flashplayer){
		throw('AudioPlayer: can not find flashplayer');
	}
	return flashplayer;
}
AudioPlayer.prototype.onUnPause = function(){
	if(this.previousContainer){
		this.setPauseImage(this.previousContainer);
	}
	this.status = 1;
}
AudioPlayer.prototype.onEndMusic = function(){
    if(this.previousFile){
        var objs = this.container.cleanWhitespace().childElements();
		for(var i=0; i < objs.length; i++){
		    if(objs[i].readAttribute('file') == this.previousFile){
			this.status = 0;
			if(i == objs.length-1) this.toggle(null, objs[0], this.noRepeat && 'paused');
			else this.toggle(null, objs[i+1]);
			break;
		    }
		}
    } else throw('AudioPlayer: can not find previous file');
}
AudioPlayer.prototype.onSetVolume = function(v){
	this.volume = parseInt(v);
}
AudioPlayer.prototype.setPauseImage = function(container){
	if(container && this.pauseImgClass){
		var image = container.select('[name="audio_toggle"]');
		if(image && image.length) image[0].className = this.pauseImgClass;
	}
	if(this.mFaviconSrc) this.changeFavicon(this.mFaviconSrc);
}
AudioPlayer.prototype.setPlayImage = function(container){
	if(container && this.playImgClass){
		var image = container.select('[name="audio_toggle"]');
		if(image && image.length) image[0].className = this.playImgClass;
	}
	if(this.mFaviconSrc) this.changeFavicon(this.defFaviconSrc);
}
AudioPlayer.prototype.addAudio = function(container){
	if(container){
		var toggles = container.select('[name="audio_toggle"]');
		for(var k=0; k < toggles.length; k++){
			toggles[k].observe('click', this.toggle.bindAsEventListener(this, container));
		}
	}
}
AudioPlayer.prototype.removeAudio = function(container){
	if(container == this.previousContainer){
		this.stop(container, container.readAttribute('file'));
	}
}

AudioPlayer.prototype.changeFavicon = function(src){
	var favicon = $$('link[rel=shortcut icon]')[0];
	if(favicon) {	
		favicon.remove();
		$$('head')[0].insert(new Element('link',
		{
			'href' : src,
			'type' : 'image/x-icon',
			'rel' : 'shortcut icon'
		}
		));
	}
}

/**
 *
 * @param {Object} sel
 * @param {String} block_on
 */
function onblock(sel, block_on){
    if (sel.value == 'other') {
        Element.show(block_on);
    }
    else {
        Element.hide(block_on);
    }
}
/**
 * Определяем top - left координаты блока obj
 * @param {Object} obj
 * @return {Object}
 */
function absPosition(obj) {
    var coords = $(obj).cumulativeOffset();
    return {x: coords[0],y: coords[1]};
}

function audio_showEditBlock(file){
	if(file){
		$('edit_author').value = $('author_'+file).innerHTML;
		$('edit_name').value = $('name_'+file).innerHTML;
                $('edit_text').value = $('text_' + file).readAttribute('value');
		$('edit_file').value = file;
		var edit = $('edit');
		var del = $('edit_button_'+file);
		edit.style.top = absPosition(del).y + del.offsetHeight;
		edit.style.display = 'block';
	}
}

var topTimeout = 0;


ну и ещё в страничке стоит скрипт назначения

<script type="text/javascript">
    var audio_player;
    function loadPlayer(container, playerTemplate, element){
if(audio_player != undefined) return;
	else { audio_player = new AudioPlayer({

		template		: playerTemplate || 'player.swf?ver=4&file=#{URL}&time=#{Time}&mid=0&vol=#{Vol}&linkshow=&linkurl=#{URL}%26&title=#{title}',
		activeFlashClass	: 'div_dashed_act ml3',
		container		: $(container),
		inActiveFlashClass	: 'div_dashed',
		playImgClass		: 'icoAudioPlay',
		pauseImgClass		: 'icoAudioPause',
		
		favicon			: 'favicon.ico',
		noRepeat		: 1
	    });
	    if(!Prototype.Browser.IE) audio_player.toggle({}, $(element));
	}
    }
	// Flash Player Callbacks
	function unPause(){ audio_player.onUnPause() }
	function setvolume(v){ audio_player.onSetVolume(v) }
	function endMusic(){ audio_player.onEndMusic() }
</script>
Ответить с цитированием