Follow along with the video below to see how to install our site as a web app on your home screen.
Примечание: This feature may not be available in some browsers.
Вставил этот плеер на Девере, правда на самописном музыкальном скрипте - всё работает и файлы сохраняет. Поэтому - видимо проблема не в плеере.
//--------------------------------------------------------------------------
// initial variables that might be useful to change
// you can insert your values at the end of the lines
//--------------------------------------------------------------------------
// toggle for which file to play > path from the swfplayer
if(_root.file) { var file:String = _root.file; } else { var file:String = "sound.mp3"; }
// toggle for the downloadbutton > true or false
if(_root.showDownload) { var showDownload:String = _root.showDownload; } else { var showDownload:String = "true"; }
// toggle for autostarting the mp3 > true or false
if(_root.autoStart) { var autoStart:String = _root.autoStart; } else { var autoStart:String = "false"; }
//toggle for repeating the mp3 > true or false
if(_root.repeatPlay) { var repeatPlay:String = _root.repeatPlay; } else { var repeatPlay:String = "false"; }
// toggle for the volume of the song > 0 to 100
if(_root.songVolume) { var songVolume:Number = int(_root.songVolume); } else { var songVolume:Number = 90; }
// toggle for the backgroundcolor of the player > hex code
if(_root.backColor) { var backColor:String = "0x"+_root.backColor; } else { var backColor:String = "0xeeeeee"; }
// toggle for the backgroundcolor of the player > hex code
if(_root.frontColor) { var frontColor:String = "0x"+_root.frontColor; } else { var frontColor:String = "0x333333"; }
// toggle for the width of the mp3player > Stage.width or a number
var w:Number = Stage.width;
//--------------------------------------------------------------------------
// functionality for playing the song
//--------------------------------------------------------------------------
var sndObject:Sound = new Sound();
var pausePos:Number = 0;
// interval ID's
var loadProgressInt:Number = new Number();
var playProgressInt:Number = new Number();
var scrubProgressInt:Number = new Number();
// loadProgress display function
function loadProgress() {
var pct:Number = sndObject.getBytesLoaded() / sndObject.getBytesTotal();
percentBar._width = pct * barWidth;
if(pct == 1) { clearInterval(loadProgressInt); }
}
// playprogress display function
function playProgress() {
var pct:Number = sndObject.position / sndObject.duration * sndObject.getBytesLoaded() / sndObject.getBytesTotal();
progressBar._width = pct * barWidth;
}
// scrub display function
function scrubProgress() {
var mouseX:Number = percentBar._xmouse * percentBar._xscale / 100;
if (mouseX > percentBar._width) { mouseX = percentBar._width; }
progressBar._width = mouseX;
var pct:Number = mouseX / barWidth;
pausePos = pct * sndObject.duration/1000;
}
// (re)start playing the song
function playSong() {
if(pausePos == 0) {
sndObject.setVolume(songVolume);
sndObject.loadSound(file,true);
loadProgressInt = setInterval(loadProgress,50);
}
sndObject.start(pausePos);
playProgressInt = setInterval(playProgress,50);
pauseBut._visible = true;
playBut._visible = false;
};
// pause the song
function pauseSong(p:Number) {
if(!p) { pausePos = sndObject.position/1000; } else { pausePos = p; }
sndObject.stop();
pauseBut._visible = false;
playBut._visible = true;
clearInterval(playProgressInt);
};
//--------------------------------------------------------------------------
// play, pause and scrubber buttons and onsoundcomplete
//--------------------------------------------------------------------------
// pause button action
pauseBut.onPress = function() {
pauseSong();
};
// play button action
playBut.onPress = function() {
playSong();
};
// start playhead scrubbing
percentBar.onPress = function() {
pauseSong();
scrubProgressInt = setInterval(scrubProgress,50);
};
// stop playhead scrubbing
percentBar.onRelease = percentBar.onReleaseOutside = function () {
clearInterval(scrubProgressInt);
playSong();
};
sndObject.onSoundComplete = function() {
if(repeatPlay == "true") {
pausePos = 0.001;
playSong();
} else {
progressBar._width = 0.1;
pauseSong(0.001);
}
}
//--------------------------------------------------------------------------
// file download functionality
//--------------------------------------------------------------------------
import flash.net.FileReference;
var listener:Object = new Object();
listener.onSelect = function(file:FileReference):Void {
trace("onSelect: " + file.name);
}
listener.onCancel = function(file:FileReference):Void {
trace("onCancel");
}
listener.onOpen = function(file:FileReference):Void {
trace("onOpen: " + file.name);
}
listener.onProgress = function(file:FileReference, bytesLoaded:Number, bytesTotal:Number):Void {
trace("onProgress with bytesLoaded: " + bytesLoaded + " bytesTotal: " + bytesTotal);
}
listener.onComplete = function(file:FileReference):Void {
trace("onComplete: " + file.name);
}
listener.onIOError = function(file:FileReference):Void {
trace("onIOError: " + file.name);
}
var fileRef:FileReference = new FileReference();
fileRef.addListener(listener);
// save button action
saveBut.onPress = function() {
var local:String = file.substr(file.lastIndexOf("/")+1);
fileRef.download(file, local);
trace(local);
};
//--------------------------------------------------------------------------
// color, resize and position all items
//--------------------------------------------------------------------------
// set all backcolors
var leftBgColor:Color = new Color(leftBg);
var centerBgColor:Color = new Color(centerBg);
var rightBgColor:Color = new Color(rightBg);
leftBgColor.setRGB(int(backColor));
centerBgColor.setRGB(int(backColor));
rightBgColor.setRGB(int(backColor));
// set all frontcolors
var playButColor:Color = new Color(playBut);
var pauseButColor:Color = new Color(pauseBut);
var percentBarColor:Color = new Color(percentBar);
var progressBarColor:Color = new Color(progressBar);
var saveButColor:Color = new Color(saveBut);
playButColor.setRGB(int(frontColor));
pauseButColor.setRGB(int(frontColor));
percentBarColor.setRGB(int(frontColor));
progressBarColor.setRGB(int(frontColor));
saveButColor.setRGB(int(frontColor));
// resize the background
leftBg._x = leftGlow._x = 0;
centerBg._x = centerGlow._x = 7;
centerBg._width = centerGlow._width = w - 14;
rightBg._x = rightGlow._x = w - 7;
// reposition the buttons
playBut._x = pauseBut._x = 12;
percentBar._x = progressBar._x = 21;
if(showDownload == "true") {
var barWidth:Number = percentBar._width = progressBar._width = w - 45;
saveBut._x = w - 17;
} else {
var barWidth:Number = percentBar._width = progressBar._width = w - 32;
}
// hide unused buttons
percentBar._alpha = 50;
pauseBut._visible = false;
progressBar._width = percentBar._width = 0;
if (w <= 35 || showDownload == "false") { saveBut._visible = false; }
if (w <= 60) { percentBar._visible = progressBar._visible = false; }
//--------------------------------------------------------------------------
// all done ? start the movie !
//--------------------------------------------------------------------------
// start playing the movie on autoStart
if (autoStart == "true") { playSong(); }