mirror of
https://github.com/wassname/phaser.git
synced 2026-07-02 17:00:42 +08:00
Fixed a bug stopping legacy Audio from starting correctly. Also fixed an issue in the Loader causing it to not load the next file if an unsupported audio file was encountered. Fixed audio playback issues on Firefox/Waterfox as a result.
This commit is contained in:
+659
-648
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,84 +0,0 @@
|
||||
<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?>
|
||||
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27 ">
|
||||
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
|
||||
<rdf:Description rdf:about=""
|
||||
xmlns:xmpDM="http://ns.adobe.com/xmp/1.0/DynamicMedia/">
|
||||
<xmpDM:Tracks>
|
||||
<rdf:Bag>
|
||||
<rdf:li rdf:parseType="Resource">
|
||||
<xmpDM:trackName>CuePoint Markers</xmpDM:trackName>
|
||||
<xmpDM:trackType>Cue</xmpDM:trackType>
|
||||
<xmpDM:frameRate>f44100</xmpDM:frameRate>
|
||||
</rdf:li>
|
||||
<rdf:li rdf:parseType="Resource">
|
||||
<xmpDM:trackName>Subclip Markers</xmpDM:trackName>
|
||||
<xmpDM:trackType>InOut</xmpDM:trackType>
|
||||
<xmpDM:frameRate>f44100</xmpDM:frameRate>
|
||||
</rdf:li>
|
||||
</rdf:Bag>
|
||||
</xmpDM:Tracks>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
xmlns:xmp="http://ns.adobe.com/xap/1.0/">
|
||||
<xmp:MetadataDate>2013-07-16T02:39:59+01:00</xmp:MetadataDate>
|
||||
<xmp:ModifyDate>2013-07-16T02:39:59+01:00</xmp:ModifyDate>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/"
|
||||
xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#"
|
||||
xmlns:stRef="http://ns.adobe.com/xap/1.0/sType/ResourceRef#">
|
||||
<xmpMM:InstanceID>xmp.iid:CF0377343CEDE211B46AA47009D9EF1D</xmpMM:InstanceID>
|
||||
<xmpMM:DocumentID>xmp.did:CF0377343CEDE211B46AA47009D9EF1D</xmpMM:DocumentID>
|
||||
<xmpMM:OriginalDocumentID>xmp.did:CE0377343CEDE211B46AA47009D9EF1D</xmpMM:OriginalDocumentID>
|
||||
<xmpMM:History>
|
||||
<rdf:Seq>
|
||||
<rdf:li rdf:parseType="Resource">
|
||||
<stEvt:action>saved</stEvt:action>
|
||||
<stEvt:instanceID>xmp.iid:CE0377343CEDE211B46AA47009D9EF1D</stEvt:instanceID>
|
||||
<stEvt:when>2013-07-16T02:39:59+01:00</stEvt:when>
|
||||
<stEvt:softwareAgent>Adobe Audition CS6 (Windows)</stEvt:softwareAgent>
|
||||
<stEvt:changed>/metadata</stEvt:changed>
|
||||
</rdf:li>
|
||||
<rdf:li rdf:parseType="Resource">
|
||||
<stEvt:action>saved</stEvt:action>
|
||||
<stEvt:instanceID>xmp.iid:CF0377343CEDE211B46AA47009D9EF1D</stEvt:instanceID>
|
||||
<stEvt:when>2013-07-16T02:39:59+01:00</stEvt:when>
|
||||
<stEvt:softwareAgent>Adobe Audition CS6 (Windows)</stEvt:softwareAgent>
|
||||
<stEvt:changed>/</stEvt:changed>
|
||||
</rdf:li>
|
||||
</rdf:Seq>
|
||||
</xmpMM:History>
|
||||
<xmpMM:DerivedFrom rdf:parseType="Resource">
|
||||
<stRef:instanceID>xmp.iid:CE0377343CEDE211B46AA47009D9EF1D</stRef:instanceID>
|
||||
<stRef:documentID>xmp.did:CE0377343CEDE211B46AA47009D9EF1D</stRef:documentID>
|
||||
<stRef:originalDocumentID>xmp.did:CE0377343CEDE211B46AA47009D9EF1D</stRef:originalDocumentID>
|
||||
</xmpMM:DerivedFrom>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/">
|
||||
<dc:format>audio/ogg; codec="vorbis"</dc:format>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
</x:xmpmeta>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<?xpacket end="w"?>
|
||||
+20
-2
@@ -1,6 +1,7 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>phaser.js - a new beginning</title>
|
||||
<?php
|
||||
require('js.php');
|
||||
@@ -15,9 +16,11 @@
|
||||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { preload: preload, create: create, update: update, render: render });
|
||||
|
||||
function preload() {
|
||||
|
||||
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
|
||||
//game.load.audio('wizball', ['assets/mp3/oedipus_wizball_highscore.ogg', 'assets/mp3/oedipus_wizball_highscore.mp3']);
|
||||
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3']);
|
||||
|
||||
// Firefox doesn't support mp3 files, so use ogg
|
||||
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
|
||||
|
||||
}
|
||||
|
||||
@@ -34,6 +37,21 @@
|
||||
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
|
||||
s.anchor.setTo(0.5, 0.5);
|
||||
|
||||
game.input.onDown.add(changeVolume, this);
|
||||
|
||||
}
|
||||
|
||||
function changeVolume(pointer) {
|
||||
|
||||
if (pointer.y < 300)
|
||||
{
|
||||
music.volume += 0.1;
|
||||
}
|
||||
else
|
||||
{
|
||||
music.volume -= 0.1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function update() {
|
||||
|
||||
+3
-3
@@ -76,7 +76,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
|
||||
* The Pixi Renderer
|
||||
* @type {number}
|
||||
*/
|
||||
this.renderType = renderer;
|
||||
this.renderer = null;
|
||||
|
||||
/**
|
||||
* The StateManager.
|
||||
@@ -94,7 +94,7 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
|
||||
* The Renderer this Phaser.Game will use. Either Phaser.RENDERER_AUTO, Phaser.RENDERER_CANVAS or Phaser.RENDERER_WEBGL
|
||||
* @type {number}
|
||||
*/
|
||||
this.renderType = 0;
|
||||
this.renderType = renderer;
|
||||
|
||||
/**
|
||||
* Whether load complete loading or not.
|
||||
@@ -334,7 +334,7 @@ Phaser.Game.prototype = {
|
||||
|
||||
setUpRenderer: function () {
|
||||
|
||||
if (this.renderType == Phaser.CANVAS || (this.renderType == Phaser.AUTO && this.device.webGL == false))
|
||||
if (this.renderType === Phaser.CANVAS || (this.renderType === Phaser.AUTO && this.device.webGL == false))
|
||||
{
|
||||
if (this.device.canvas)
|
||||
{
|
||||
|
||||
@@ -49,6 +49,8 @@ Phaser.Cache = function (game) {
|
||||
|
||||
this.addDefaultImage();
|
||||
|
||||
this.onSoundUnlock = new Phaser.Signal;
|
||||
|
||||
};
|
||||
|
||||
Phaser.Cache.prototype = {
|
||||
|
||||
@@ -471,7 +471,7 @@ Phaser.Loader.prototype = {
|
||||
{
|
||||
if (this.game.sound.touchLocked)
|
||||
{
|
||||
// If audio is locked we can't do this yet, so need to queue this load request somehow. Bum.
|
||||
// If audio is locked we can't do this yet, so need to queue this load request. Bum.
|
||||
file.data = new Audio();
|
||||
file.data.name = file.key;
|
||||
file.data.preload = 'auto';
|
||||
@@ -492,6 +492,10 @@ Phaser.Loader.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.fileError(file.key);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
|
||||
+24
-12
@@ -56,10 +56,15 @@ Phaser.Sound = function (game, key, volume, loop) {
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.game.cache.getSound(key) && this.game.cache.getSound(key).locked == false)
|
||||
if (this.game.cache.getSound(key) && this.game.cache.isSoundReady(key))
|
||||
{
|
||||
this._sound = this.game.cache.getSoundData(key);
|
||||
this.totalDuration = this._sound.duration;
|
||||
this.totalDuration = 0;
|
||||
|
||||
if (this._sound.duration)
|
||||
{
|
||||
this.totalDuration = this._sound.duration;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -86,7 +91,7 @@ Phaser.Sound.prototype = {
|
||||
{
|
||||
this._sound = this.game.cache.getSoundData(this.key);
|
||||
this.totalDuration = this._sound.duration;
|
||||
// console.log('sound has unlocked' + this._sound);
|
||||
console.log('sound has unlocked' + this._sound);
|
||||
}
|
||||
|
||||
},
|
||||
@@ -298,24 +303,28 @@ Phaser.Sound.prototype = {
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log('Sound play Audio');
|
||||
// console.log('Sound play Audio');
|
||||
if (this.game.cache.getSound(this.key) && this.game.cache.getSound(this.key).locked)
|
||||
{
|
||||
//console.log('tried playing locked sound, pending set, reload started');
|
||||
// console.log('tried playing locked sound, pending set, reload started');
|
||||
this.game.cache.reloadSound(this.key);
|
||||
this.pendingPlayback = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
//console.log('sound not locked, state?', this._sound.readyState);
|
||||
// console.log('sound not locked, state?', this._sound.readyState);
|
||||
if (this._sound && this._sound.readyState == 4)
|
||||
{
|
||||
this._sound.play();
|
||||
// This doesn't become available until you call play(), wonderful ...
|
||||
this.totalDuration = this._sound.duration;
|
||||
|
||||
if (this.duration == 0)
|
||||
{
|
||||
this.duration = this.totalDuration * 1000;
|
||||
}
|
||||
|
||||
//console.log('playing', this._sound);
|
||||
// console.log('playing', this._sound);
|
||||
this._sound.currentTime = this.position;
|
||||
this._sound.muted = this._muted;
|
||||
|
||||
@@ -328,7 +337,6 @@ Phaser.Sound.prototype = {
|
||||
this._sound.volume = this._volume;
|
||||
}
|
||||
|
||||
this._sound.play();
|
||||
this.isPlaying = true;
|
||||
this.startTime = this.game.time.now;
|
||||
this.currentTime = 0;
|
||||
@@ -507,15 +515,19 @@ Object.defineProperty(Phaser.Sound.prototype, "volume", {
|
||||
|
||||
set: function (value) {
|
||||
|
||||
this._volume = value;
|
||||
|
||||
if (this.usingWebAudio)
|
||||
{
|
||||
this._volume = value;
|
||||
this.gainNode.gain.value = value;
|
||||
}
|
||||
else if(this.usingAudioTag && this._sound)
|
||||
else if (this.usingAudioTag && this._sound)
|
||||
{
|
||||
this._sound.volume = value;
|
||||
// Causes an Index size error in Firefox if you don't clamp the value
|
||||
if (value >= 0 && value <= 1)
|
||||
{
|
||||
this._volume = value;
|
||||
this._sound.volume = value;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
@@ -105,9 +105,16 @@ Phaser.Canvas = {
|
||||
parent = parent || '';
|
||||
overflowHidden = overflowHidden || true;
|
||||
|
||||
if ((parent !== '' || parent !== null) && document.getElementById(parent))
|
||||
if (parent !== '')
|
||||
{
|
||||
document.getElementById(parent).appendChild(canvas);
|
||||
if (document.getElementById(parent))
|
||||
{
|
||||
document.getElementById(parent).appendChild(canvas);
|
||||
}
|
||||
else
|
||||
{
|
||||
document.body.appendChild(canvas);
|
||||
}
|
||||
|
||||
if (overflowHidden)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user