Results 1 to 4 of 4

Thread: Trying to implement isPlaying on iOS

  1. #1

    Default Trying to implement isPlaying on iOS

    Apparently one would have to use the AudioServicesAddSystemSoundCompletion which calls back a user function when a player stops playing. Right before the AudioServicesPlaySystemSound.

    So I thought I'd add a variable bool isPlaying in class AudioObjectOS which will be changed to false in the user function when the system calls it.

    Now, the compiler won't shut up about passing the pointer to the user function in AudioServicesAddSystemSoundCompletion unless that function is declared static which will deny me access to m_audioList. If I put m_audioList static, now the linker starts to complain.

    I tested the code without it doing anything and the system calls back my function when something stopped playing, the only problem is how can I use this without making the function static?

  2. #2

    Default

    Fixed it. Use like this

    in AudioHandle AudioManagerOS::Play
    Code:
    	
    ...
    AudioObjectOS *pAudio = GetAudioObjectByFileName(fName, bLooping);
    	if (!pAudio) return soundId;
    
    	soundId = pAudio->m_id;
    	AudioServicesAddSystemSoundCompletion( soundId, NULL, NULL, SetStoppedPlaying, (void*)this);
    	AudioServicesPlaySystemSound(soundId);
    ...

    After telling it to play, you need to set isPlaying to true, but since I'm not using string and list classes, this is how it looks in my code. Hope it makes sence

    Code:
    	for (int c = 0 ; c < m_audioListSize ; c++)
    		if (strcmp(m_audioList[c]->fName, fName) == 0)
    			m_audioList[c]->isPlaying = true;
    in AudioManagerOS.h

    Code:
    static void SetStoppedPlaying(SystemSoundID id, void *mySelf);
    And
    Code:
    void AudioManagerOS::SetStoppedPlaying(SystemSoundID id, void *mySelf)
    {
    	for (int c = 0 ; c < ((AudioManagerOS*)mySelf)->m_audioListSize ; c++)
    		if (((AudioManagerOS*)mySelf)->m_audioList[c]->m_id == id)
    			((AudioManagerOS*)mySelf)->m_audioList[c]->isPlaying = false;
    }
    Since -> has priority over casting, use ((AudioManagerOS*)mySelf)-> or you'll get some weird errors.
    Last edited by Etek; 11-28-2010 at 10:30 PM.

  3. #3
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,340

    Default

    Nice work! Can I add this to Proton? If there is more to it then what you've posted could you possibly attach a patched created with SVN for me?
    Seth A. Robinson
    Robinson Technologies

  4. #4

    Default

    Of course you can, the only thing I forgot to add is

    Code:
    	bool isPlaying;
    in the public part of class AudioObjectOS

    I am not sure what you mean here, my english is not my first language, sorry.

    If there is more to it then what you've posted could you possibly attach a patched created with SVN for me?

Similar Threads

  1. What I would need to do to implement a new entity type or something?
    By speeder in forum Novashell Game Creation System
    Replies: 1
    Last Post: 08-18-2010, 05:10 AM
  2. Some requested things to implement
    By SLATE in forum Funeral Quest
    Replies: 6
    Last Post: 09-27-2004, 04:59 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •