2010-09-13 50 views
0

我有一些AS3 MP3代碼,我的老師給我一段時間,當我在我的電腦上本地加載網站時,但我上傳了網站到我的服務器和MP3根本不加載,但網站的其餘部分是好的。由於我對AS3並不擅長,也不安靜地理解所發生的一切,所以我只是想整個發佈MP3代碼,以防萬一你們發現它爲什麼不能加載在線。順便說一下,我只從bluehost.com購買了基本的服務器空間。我沒有購買媒體服務器(我真的不知道它做了什麼)。這可能是問題嗎?AS3 MP3播放器在本地打開時載入,但在我的服務器上根本沒有顯示

var songList:Array = new Array("InBackRoom.mp3", "NoMeansYes.mp3"); 
var isPlaying:Boolean = false; 
var currentSong:Number = 0; 
var song:Sound; 
var channel:SoundChannel = new SoundChannel(); 
var xform:SoundTransform = new SoundTransform(); 

seekKnob.buttonMode = true; 
seekKnob.addEventListener(MouseEvent.MOUSE_DOWN, seekStartDrag); 
btnPrev.addEventListener(MouseEvent.CLICK, prevHandler); 
btnPause.addEventListener(MouseEvent.CLICK, pauseHandler); 
btnPlay.addEventListener(MouseEvent.CLICK, playHandler); 
btnNext.addEventListener(MouseEvent.CLICK, nextHandler); 
volumeKnob.buttonMode = true; 
volumeKnob.addEventListener(MouseEvent.MOUSE_DOWN, volumeStartDrag); 

function prevHandler(evt:MouseEvent):void { 
    prevSong(); 
} 

function pauseHandler(evt:MouseEvent):void { 
    pauseSong(); 
} 

function playHandler(evt:MouseEvent):void { 
    playSong(channel.position); 
} 

function nextHandler(evt:MouseEvent):void { 
    nextSong(); 
} 

function id3Handler(evt:Event):void { 
    songInfo.text = /*song.id3.artist + ": " +*/ song.id3.songName; 
} 
function soundCompleteHandler(evt:Event):void { 
    pauseSong(); 
    nextSong(); 
} 

loadSong(songList[currentSong]); 

function loadSong(thisSong:String):void { 
    song = new Sound(); 
    song.load(new URLRequest(thisSong)); 
    song.addEventListener(Event.ID3, id3Handler); 
    /*playSong(0);*/ 
} 

function playSong(position:Number):void { 
    if (!isPlaying) { 
     isPlaying = true; 
     channel = song.play(position); 
     channel.soundTransform = xform; 
     channel.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler); 
     seekKnob.addEventListener(Event.ENTER_FRAME, seekKnobUpdate); 
    } 
} 

function pauseSong():void { 
    seekKnob.removeEventListener(Event.ENTER_FRAME, seekKnobUpdate); 
    channel.stop(); 
    isPlaying = false; 
} 

function prevSong():void { 
    if (currentSong > 0) { 
     currentSong--; 
     pauseSong(); 
     loadSong(songList[currentSong]); 
    } 
} 

function nextSong():void { 
    if (currentSong < songList.length - 1) { 
     currentSong++; 
     pauseSong(); 
     loadSong(songList[currentSong]); 
    } 
} 

function seekStartDrag(evt:MouseEvent):void { 
    pauseSong(); 
    seekKnob.startDrag(true, new Rectangle(seekSlider.x, seekSlider.y + seekSlider.height/2, seekSlider.width, 0)); 
    stage.addEventListener(MouseEvent.MOUSE_UP, seekStopDrag); 
} 

function seekStopDrag(evt:MouseEvent):void { 
    seekKnob.stopDrag(); 
    playSong(song.length * (seekKnob.x - seekSlider.x)/seekSlider.width); 
    stage.removeEventListener(MouseEvent.MOUSE_UP, seekStopDrag); 
} 

function seekKnobUpdate(evt:Event):void { 
    var pos:Number = seekSlider.width * channel.position/song.length; 
    if (!isNaN(pos)) { 
     seekKnob.x = seekSlider.x + pos; 
    } else { 
     seekKnob.x = seekSlider.x; 
    } 
} 

function volumeStartDrag(evt:MouseEvent):void { 
    volumeKnob.startDrag(true, new Rectangle(volumeSlider.x, volumeSlider.y + volumeSlider.height/2, volumeSlider.width, 0)); 
    volumeKnob.addEventListener(MouseEvent.MOUSE_MOVE, volumeUpdate); 
    stage.addEventListener(MouseEvent.MOUSE_UP, volumeStopDrag); 
} 

function volumeStopDrag(evt:MouseEvent):void { 
    volumeKnob.removeEventListener(MouseEvent.MOUSE_MOVE, volumeUpdate); 
    volumeKnob.stopDrag(); 
    stage.removeEventListener(MouseEvent.MOUSE_UP, volumeStopDrag); 
} 

function volumeUpdate(evt:MouseEvent):void { 
    xform.volume = (volumeKnob.x - volumeSlider.x)/volumeSlider.width; 
    channel.soundTransform = xform; 
} 

我檢查了一切,並上傳了相同的,正確的文件結構,它應該是。

+1

你有沒有得到任何錯誤?如果您使用Flash Player的調試版本(adobe.com/support/flashplayer/downloads.html),您應該會看到錯誤。我想象一個IOError或SecuritySandbox錯誤。 – 2010-09-13 12:31:24

回答

1

沒有必要使用媒體服務器。使用Firebug等網絡調試器查看是否正在製作MP3文件的請求,以及製作的位置以及響應是否合適。它可能像url中區分大小寫一樣簡單。

+0

我不認爲這可能是因爲我用fireFTP上傳了一切...意思我只是單擊並拖動了所有從我的電腦上運行的文件到我在線的文件空間...我將通過並檢查一切,但我相對比較確信,如果任何網址或大小寫敏感性本來就沒有關閉,它不會在我的電腦上工作,在本地。 – mike 2010-09-13 21:07:46

+0

你有沒有試過Firebug? – spender 2010-09-13 23:28:47

+0

我是螢火蟲,但我不知道你可以用它閃光?? – mike 2010-09-15 13:17:13

相關問題