title: Passing a function to another function on a separate component in Ionic 2 or 3
body: <p>a bit of a tricky one here. I've been trying to wrap my head around this one with no success. Ok, here it goes... I've got a function in a different ionic component set out like this:</p>
  
  <p><strong>home.ts</strong></p>
  
  <pre><code>   playAudio() { 
  
      this.streamingMedia.playAudio('MY-URL');
  
      this.play = false;
  
      }
  
      stopAudio() {
      this.streamingMedia.stopAudio();
  
      this.play = true;
      }
  </code></pre>
  
  <p>Then I set up this boolean within the same home.ts file to toggle between the play and pause buttons</p>
  
  <pre><code>play: boolean = true;
  </code></pre>
  
  <p>Now, in my home.html file I have it setup as follows:</p>
  
  <p><strong>home.html</strong></p>
  
  <pre><code>&lt;div *ngIf="play"&gt;
  &lt;img src="assets/img/play.png" class="play" (tap)="playAudio()" /&gt;
  &lt;/div&gt;
  
  &lt;div *ngIf="!play"&gt;
  &lt;img src="assets/img/pause.png" class="play animated flip"     
  (tap)="stopAudio()" /&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Essentially what is happening here is, when I click the play button, play starts and then it shows the pause button. And likewise, when I click the pause button, play stops and shows the play button.</p>
  
  <p>So, here is my problem, I'm trying to call the function in a different page/component. I want it to automatically play the stream when I open the page, I tried doing that by writing the same <code>playAudio()</code> function (as in the home.ts file) in the app.component.ts file where I need to set the function:</p>
  
  <p><strong>app.component.ts</strong></p>
  
  <pre><code>play: boolean = true;
  
  constructor() {
  this.playAudio(); }
  
  playAudio() {       
  this.streamingMedia.playAudio('MY_URL');
  this.play = false;
  }
  </code></pre>
  
  <p>but when the page opens, the stream plays but I then don't have the option to set the pause button in place of the play button.</p>
  
  <p>I hope I'm making sense. </p>