diff --git a/src/com/upc/pbe/upcnews/HLS.java b/src/com/upc/pbe/upcnews/HLS.java index 0e0de9d..fb26313 100644 --- a/src/com/upc/pbe/upcnews/HLS.java +++ b/src/com/upc/pbe/upcnews/HLS.java @@ -1,7 +1,6 @@ package com.upc.pbe.upcnews; import java.io.File; -import java.io.IOException; import java.util.ArrayList; import android.util.Log; @@ -47,7 +46,7 @@ public class HLS } } - public String next() throws IOException + public String next() { // Determina la seguent qualitat a partir de la velocitat if (currentSegment == segments.size()) diff --git a/src/com/upc/pbe/upcnews/Parser.java b/src/com/upc/pbe/upcnews/Parser.java index 0c9d63f..20b7c17 100644 --- a/src/com/upc/pbe/upcnews/Parser.java +++ b/src/com/upc/pbe/upcnews/Parser.java @@ -496,7 +496,7 @@ public class Parser } else if (line.startsWith("/")) { - line = server + line; + line = "http://" + server + line; } pls.getSegments().get(currentSegment).setURL(line); } diff --git a/src/com/upc/pbe/upcnews/VideoActivity.java b/src/com/upc/pbe/upcnews/VideoActivity.java index 11f805e..ab32324 100644 --- a/src/com/upc/pbe/upcnews/VideoActivity.java +++ b/src/com/upc/pbe/upcnews/VideoActivity.java @@ -86,30 +86,28 @@ public class VideoActivity extends Activity { downloadSegment(getNext()); } - public String getNext() { - try { + public String getNext() + { return h.next(); - } - catch(IOException e) { - Toast.makeText(this, "No s'ha trobat el segment", Toast.LENGTH_LONG).show(); - super.finish(); - return ""; - } } public void toggleBuffering(boolean b) { - if(b && pd == null) + if(b) { - pd = new ProgressDialog(VideoActivity.this); - pd.setCancelable(false); - pd.setMessage(getString(R.string.buffering_text)); + buffering = true; + if(pd == null) + { + pd = new ProgressDialog(VideoActivity.this); + pd.setCancelable(false); + pd.setMessage(getString(R.string.buffering_text)); + } pd.show(); } - else if(pd != null) + else { + buffering = false; pd.dismiss(); - pd = null; } } @@ -122,7 +120,6 @@ public class VideoActivity extends Activity { public void buffer() { - buffering = true; toggleBuffering(true); video.suspend(); } @@ -187,9 +184,13 @@ public class VideoActivity extends Activity { } catch (MalformedURLException e) { - e.printStackTrace(); + Toast.makeText(this, "URL malformada", Toast.LENGTH_LONG).show(); } } + public void showNotFound(String url) + { + Toast.makeText(this, "No s'ha trobat el segment " + url, Toast.LENGTH_LONG).show(); + } @Override public void onConfigurationChanged(Configuration newConfig) { @@ -202,11 +203,13 @@ public class VideoActivity extends Activity { { final static String TAG = "DescarregaSegment"; private long bps; + boolean failed; + String url; public DescarregaSegment() { bps = 0; - pd = null; + failed = false; } @Override @@ -248,8 +251,9 @@ public class VideoActivity extends Activity { } catch(IOException e) { + url = urls[0].toString(); + failed = true; this.cancel(true); - Toast.makeText(VideoActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); return null; } return null; @@ -260,10 +264,13 @@ public class VideoActivity extends Activity { { return; } - - if(!queue.isEmpty() && buffering) + if(failed) + { + failed = false; + showNotFound(url); + } + else if(!queue.isEmpty() && buffering) { - buffering = false; play(queue.get(0)); } String newSegment = null;