Having trouble playing music using IPython
<p>I have the lines of code</p>

<pre><code>import IPython        
IPython.display.Audio(url="http://www.1happybirthday.com/PlaySong/Anna",embed=True,autoplay=True)
</code></pre>

<p>And I'm not really sure what's wrong. I am using try.jupyter.org to run my code, and this is within if statements. The notebook is also taking in user inputs and printing outputs. It gives no error, but just doesn't show up/start playing. I'm not really sure what's wrong.</p>

<p>Any help would be appreciated. Thanks!</p>

<p>First you should try it without the <code>if</code> statement. Just the two lines you mention above. This will still not work, because your URL does point to an HTML page instead of a sound file. In your case the correct URL would be <code>'https://s3-us-west-2.amazonaws.com/1hbcf/Anna.mp3'</code>.</p>

<p>The <code>Audio</code> object which you are creating, will only be displayed if it is the last statement in a notebook cell. See <a href="http://nbviewer.jupyter.org/github/mgeier/python-audio/blob/master/intro-python.ipynb" rel="nofollow">my Python intro</a> for details. If you want to use it within an <code>if</code> clause, you can use <code>IPython.display.display()</code> like this:</p>

<pre><code>url = 'https://s3-us-west-2.amazonaws.com/1hbcf/Anna.mp3'
if 3 &lt; 5:
    IPython.display.display(IPython.display.Audio(url=url, autoplay=True))
else:
    print('Hello!')
</code></pre>

python audio ipython jupyter-notebook