I have a problem since two days researching more I could not solve.
I have an app in a class that runs a streaming audio. In another view, I have a table with podcasts that will be opened via url.
In order to take advantage of the code of the first class created a delegate, so when the User goes to play in any audio podcast I occupy the methods of the main class just changing the parameters (in this case the URL).
The delegate works correctly, the passing of parameters too. The only problem is that the delegate have to instantiate the main class.
ClassePrincipal *classePrincipal = [[ClassePrincipal alloc] init];
classePrincipal.delegate = self;
[classePrincipal method];
If the audio is already running in the main class, instantiated as a new object class, it will start playing the audio Podcast on top of what was already running.
and even if I have a major stop before he continues to play the podcast, eg:
- (void) playPodcast {
[classePrincipal destroyStreamer];
[classePrincipal startStream];
}
destroyStreamer the method is called correctly, but as the instance was created from scratch classePrincipal he did not see any audio being played.
kind of rolled the question, but is there any way to call a method of parameter passing ClassePrincipal without instantiating the class? For not allocating a new object in memory, I could see if the audio is playing and for him.
if there is any other way to solve also thank.
From what I can tell you may want to turn this class into a singleton. This way you will be instantiating it if its not already and if it has already been instantiated you can just place some checks in your code to stop the current audio before starting the new. A random tutorial I found is enter link description here