Browse Source

Add mp3 volume function
"setiOSAudioStreamVolume"

Paul Jan 12 years ago
parent
commit
85d2423

+ 13 - 0
engine/source/audio/audioFunctions.cc

@@ -726,6 +726,19 @@ ConsoleFunction(stopiOSAudioStream, void, 2, 2, "( streamId ) - Stops playing th
     }
 }
 
+ConsoleFunction(setiOSAudioStreamVolume, void, 3, 3, "setiPhoneAudioVolume( Stream ID, float volume )" )
+{
+    SimObjectId streamId = dAtoi( argv[1] );
+    iOSStreamSource* pStream = Sim::findObject<iOSStreamSource>( streamId );
+    
+    F32 volume = dAtof( argv[2] );
+    
+    if( pStream ) {
+        if( pStream->isPlaying() ) {
+            pStream->setVolume(volume);
+        }
+    }
+}
 #endif
 
 

+ 5 - 0
engine/source/platformiOS/iOSStreamSource.cc

@@ -60,3 +60,8 @@ bool iOSStreamSource::stop() {
 	SoundEngine::SoundEngine_UnloadBackgroundMusicTrack();
 	return true;
 }
+    
+bool iOSStreamSource::setVolume( F32 volume) {
+    SoundEngine::SoundEngine_SetBackgroundMusicVolume(volume);
+    return true;
+}

+ 1 - 0
engine/source/platformiOS/iOSStreamSource.h

@@ -34,6 +34,7 @@ class iOSStreamSource: public SimObject
 	bool isPlaying();
 	bool start( bool loop = false );
 	bool stop();
+    bool setVolume( F32 volume);
 };
 
 #endif // _AUDIOSTREAMSOURCE_H_