Repository: holoviz/panel

Issue:
Panel 0.8.0rc3 Audio pane broken loading .wav (conda install)
#### ALL software version info (this library, plus any other relevant software, e.g. bokeh, python, notebook, OS, browser, etc)
- OS: Ubuntu 18.04.3 LTS 64-bit
- Browser: Firefox 72.0.1 (64-bit)
- Jupyter Notebook (same problem in Jupyter Lab)
- Fresh conda environment with the following packages (install with `conda install -c pyviz/label/dev panel`)

<details><summary>Conda environment packages (CLICK ME)</summary>
<p>

`conda list`:
```
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
asn1crypto                1.3.0                    py38_0  
attrs                     19.3.0                     py_0  
backcall                  0.1.0                    py38_0  
blas                      1.0                         mkl  
bleach                    3.1.0                      py_0  
bokeh                     1.4.0                    py38_0  
ca-certificates           2019.11.27                    0  
certifi                   2019.11.28               py38_0  
cffi                      1.13.2           py38h2e261b9_0  
chardet                   3.0.4                 py38_1003  
cryptography              2.8              py38h1ba5d50_0  
decorator                 4.4.1                      py_0  
defusedxml                0.6.0                      py_0  
entrypoints               0.3                      py38_0  
freetype                  2.9.1                h8a8886c_1  
gmp                       6.1.2                h6c8ec71_1  
idna                      2.8                   py38_1000  
importlib_metadata        1.4.0                    py38_0  
intel-openmp              2019.4                      243  
ipykernel                 5.1.4            py38h39e3cac_0  
ipython                   7.11.1           py38h39e3cac_0  
ipython_genutils          0.2.0                    py38_0  
ipywidgets                7.5.1                      py_0  
jedi                      0.16.0                   py38_0  
jinja2                    2.10.3                     py_0  
jpeg                      9b                   h024ee3a_2  
jsonschema                3.2.0                    py38_0  
jupyter_client            5.3.4                    py38_0  
jupyter_core              4.6.1                    py38_0  
ld_impl_linux-64          2.33.1               h53a641e_7  
libedit                   3.1.20181209         hc058e9b_0  
libffi                    3.2.1                hd88cf55_4  
libgcc-ng                 9.1.0                hdf63c60_0  
libgfortran-ng            7.3.0                hdf63c60_0  
libpng                    1.6.37               hbc83047_0  
libsodium                 1.0.16               h1bed415_0  
libstdcxx-ng              9.1.0                hdf63c60_0  
libtiff                   4.1.0                h2733197_0  
markdown                  3.1.1                    py38_0  
markupsafe                1.1.1            py38h7b6447c_0  
mistune                   0.8.4           py38h7b6447c_1000  
mkl                       2019.4                      243  
mkl-service               2.3.0            py38he904b0f_0  
mkl_fft                   1.0.15           py38ha843d7b_0  
mkl_random                1.1.0            py38h962f231_0  
more-itertools            8.0.2                      py_0  
nbconvert                 5.6.1                    py38_0  
nbformat                  5.0.4                      py_0  
ncurses                   6.1                  he6710b0_1  
notebook                  6.0.3                    py38_0  
numpy                     1.18.1           py38h4f9e942_0  
numpy-base                1.18.1           py38hde5b4d6_1  
olefile                   0.46                       py_0  
openssl                   1.1.1d               h7b6447c_3  
packaging                 20.1                       py_0  
pandoc                    2.2.3.2                       0  
pandocfilters             1.4.2                    py38_1  
panel                     0.8.0rc3                   py_0    pyviz/label/dev
param                     1.10.0a2                   py_0    pyviz/label/dev
parso                     0.6.0                      py_0  
pexpect                   4.8.0                    py38_0  
pickleshare               0.7.5                 py38_1000  
pillow                    7.0.0            py38hb39fc2d_0  
pip                       20.0.2                   py38_0  
prometheus_client         0.7.1                      py_0  
prompt_toolkit            3.0.2                      py_0  
ptyprocess                0.6.0                    py38_0  
pycparser                 2.19                       py_0  
pyct                      0.4.6                      py_0    pyviz/label/dev
pyct-core                 0.4.6                      py_0    pyviz/label/dev
pygments                  2.5.2                      py_0  
pyopenssl                 19.1.0                   py38_0  
pyparsing                 2.4.6                      py_0  
pyrsistent                0.15.7           py38h7b6447c_0  
pysocks                   1.7.1                    py38_0  
python                    3.8.1                h0371630_1  
python-dateutil           2.8.1                      py_0  
pyviz_comms               0.7.3                      py_0    pyviz/label/dev
pyyaml                    5.2              py38h7b6447c_0  
pyzmq                     18.1.0           py38he6710b0_0  
readline                  7.0                  h7b6447c_5  
requests                  2.22.0                   py38_1  
send2trash                1.5.0                    py38_0  
setuptools                45.1.0                   py38_0  
six                       1.14.0                   py38_0  
sqlite                    3.30.1               h7b6447c_0  
terminado                 0.8.3                    py38_0  
testpath                  0.4.4                      py_0  
tk                        8.6.8                hbc83047_0  
tornado                   6.0.3            py38h7b6447c_0  
tqdm                      4.42.0                     py_0  
traitlets                 4.3.3                    py38_0  
urllib3                   1.25.8                   py38_0  
wcwidth                   0.1.7                    py38_0  
webencodings              0.5.1                    py38_1  
wheel                     0.33.6                   py38_0  
widgetsnbextension        3.5.1                    py38_0  
xz                        5.2.4                h14c3975_4  
yaml                      0.1.7                had09818_2  
zeromq                    4.3.1                he6710b0_3  
zipp                      0.6.0                      py_0  
zlib                      1.2.11               h7b6447c_3  
zstd                      1.3.7                h0b5b093_0
```

</p>
</details>

#### Description of expected behavior and the observed behavior
- Expected: An audio widget which can play audio
- Observed: AttributeError

#### Complete, minimal, self-contained example code that reproduces the issue
Download any .wav file and put it in the same folder (I downloaded this file: https://freewavesamples.com/ensoniq-esq-1-sympy-c4)

```python
import panel as pn
pn.extension()

pn.pane.Audio("Ensoniq-ESQ-1-Sympy-C4.wav")
```

#### Stack traceback and/or browser JavaScript console output
```python
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/anaconda3/envs/panel08/lib/python3.8/site-packages/IPython/core/formatters.py in __call__(self, obj, include, exclude)
    968 
    969             if method is not None:
--> 970                 return method(include=include, exclude=exclude)
    971             return None
    972         else:

~/anaconda3/envs/panel08/lib/python3.8/site-packages/panel/viewable.py in _repr_mimebundle_(self, include, exclude)
    404         comm = state._comm_manager.get_server_comm()
    405         doc = _Document()
--> 406         model = self._render_model(doc, comm)
    407 
    408         if config.debug != 'disable':

~/anaconda3/envs/panel08/lib/python3.8/site-packages/panel/viewable.py in _render_model(self, doc, comm)
    355         if comm is None:
    356             comm = state._comm_manager.get_server_comm()
--> 357         model = self.get_root(doc, comm)
    358 
    359         if config.embed:

~/anaconda3/envs/panel08/lib/python3.8/site-packages/panel/pane/base.py in get_root(self, doc, comm)
    250         doc = doc or _curdoc()
    251         if self._updates:
--> 252             root = self._get_model(doc, comm=comm)
    253         else:
    254             root = self.layout._get_model(doc, comm=comm)

~/anaconda3/envs/panel08/lib/python3.8/site-packages/panel/pane/media.py in _get_model(self, doc, root, parent, comm)
     66 
     67     def _get_model(self, doc, root=None, parent=None, comm=None):
---> 68         props = self._process_param_change(self._init_properties())
     69         model = self._bokeh_model(**props)
     70         if root is None:

~/anaconda3/envs/panel08/lib/python3.8/site-packages/panel/pane/media.py in _process_param_change(self, msg)
     89                 data = b64encode(buffer.getvalue())
     90             elif os.path.isfile(value):
---> 91                 fmt = object.split('.')[-1]
     92                 with open(object, 'rb') as f:
     93                     data = f.read()

AttributeError: type object 'object' has no attribute 'split'
```

Out[]:
```
Audio(str)
```
#### Screenshots or screencasts of the bug in action



Discussion:

Resolving patch:
diff --git a/panel/pane/media.py b/panel/pane/media.py
--- a/panel/pane/media.py
+++ b/panel/pane/media.py
@@ -88,8 +88,8 @@ def _process_param_change(self, msg):
                 buffer = self._from_numpy(value)
                 data = b64encode(buffer.getvalue())
             elif os.path.isfile(value):
-                fmt = object.split('.')[-1]
-                with open(object, 'rb') as f:
+                fmt = value.split('.')[-1]
+                with open(value, 'rb') as f:
                     data = f.read()
                 data = b64encode(data)
             elif value.lower().startswith('http'):


Test patch: