Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...
Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...
Sviluppo di una piattaforma per lo streaming multimediale - MobiLab ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
}<br />
<strong>Sviluppo</strong> <strong>di</strong> <strong>una</strong> <strong>piattaforma</strong> <strong>per</strong> <strong>lo</strong> <strong>streaming</strong> multime<strong>di</strong>ale in ambiente Android<br />
mp.setAu<strong>di</strong>oStreamType(2);<br />
mp.setDisplay((SurfaceHolder)<br />
mPreview.getHolder().getSurface());<br />
// Creazione del tread <strong>di</strong> control<strong>lo</strong>, creazione e down<strong>lo</strong>ad<br />
// della dataSource → idealmente il nostro HandoffClient<br />
Thread r = new Thread() {<br />
public void run() {<br />
try {<br />
setDataSource(path);<br />
} catch (IOException e) {<br />
Log.e(TAG, e.getMessage(), e);<br />
}<br />
try {<br />
mp.prepare();<br />
} catch (IllegalStateException e) {<br />
// TODO Auto-generated catch b<strong>lo</strong>ck<br />
e.printStackTrace();<br />
} catch (IOException e) {<br />
// TODO Auto-generated catch b<strong>lo</strong>ck<br />
e.printStackTrace();<br />
}<br />
Log.v(TAG, "Durata: " + mp.getDuration());<br />
mp.start();<br />
}<br />
};<br />
new Thread(r).start();<br />
} catch (Exception e) {<br />
Log.e(TAG, "errore: " + e.getMessage(), e);<br />
if (mp != null) {<br />
mp.stop();<br />
mp.release();<br />
}<br />
}<br />
private void setDataSource(String path) throws IOException {<br />
// override del metodo setdatasource definito dal player, in cui<br />
// inserire la conversione dei dati estratti dal<br />
// BufferedReader.java<br />
if (!URLUtil.isNetworkUrl(path)) {<br />
mp.setDataSource(path);<br />
}<br />
public boolean onError(Me<strong>di</strong>aPlayer me<strong>di</strong>aPlayer, int iderr, int extra) {<br />
Log.e(TAG, "onError id: " + iderr + " extra: " + extra);<br />
if (me<strong>di</strong>aPlayer != null) {<br />
me<strong>di</strong>aPlayer.stop();<br />
me<strong>di</strong>aPlayer.release();<br />
return true;<br />
}<br />
return false;<br />
}<br />
[…] Omissis […] // ulteriori overrides dei meto<strong>di</strong> <strong>di</strong> android.me<strong>di</strong>a.Me<strong>di</strong>aPlayer<br />
80