Commit e0c3f3a00bb392e335d117eafcb6a96d39868970

Authored by Imanol-Mikel Barba Sabariego
1 parent 50c012ea

Bugs con rutas y progressDialog fixed

src/com/upc/pbe/upcnews/HLS.java
1 1 package com.upc.pbe.upcnews;
2 2  
3 3 import java.io.File;
4   -import java.io.IOException;
5 4 import java.util.ArrayList;
6 5  
7 6 import android.util.Log;
... ... @@ -47,7 +46,7 @@ public class HLS
47 46 }
48 47 }
49 48  
50   - public String next() throws IOException
  49 + public String next()
51 50 {
52 51 // Determina la seguent qualitat a partir de la velocitat
53 52 if (currentSegment == segments.size())
... ...
src/com/upc/pbe/upcnews/Parser.java
... ... @@ -496,7 +496,7 @@ public class Parser
496 496 }
497 497 else if (line.startsWith("/"))
498 498 {
499   - line = server + line;
  499 + line = "http://" + server + line;
500 500 }
501 501 pls.getSegments().get(currentSegment).setURL(line);
502 502 }
... ...
src/com/upc/pbe/upcnews/VideoActivity.java
... ... @@ -86,30 +86,28 @@ public class VideoActivity extends Activity {
86 86 downloadSegment(getNext());
87 87 }
88 88  
89   - public String getNext() {
90   - try {
  89 + public String getNext()
  90 + {
91 91 return h.next();
92   - }
93   - catch(IOException e) {
94   - Toast.makeText(this, "No s'ha trobat el segment", Toast.LENGTH_LONG).show();
95   - super.finish();
96   - return "";
97   - }
98 92 }
99 93  
100 94 public void toggleBuffering(boolean b)
101 95 {
102   - if(b && pd == null)
  96 + if(b)
103 97 {
104   - pd = new ProgressDialog(VideoActivity.this);
105   - pd.setCancelable(false);
106   - pd.setMessage(getString(R.string.buffering_text));
  98 + buffering = true;
  99 + if(pd == null)
  100 + {
  101 + pd = new ProgressDialog(VideoActivity.this);
  102 + pd.setCancelable(false);
  103 + pd.setMessage(getString(R.string.buffering_text));
  104 + }
107 105 pd.show();
108 106 }
109   - else if(pd != null)
  107 + else
110 108 {
  109 + buffering = false;
111 110 pd.dismiss();
112   - pd = null;
113 111 }
114 112 }
115 113  
... ... @@ -122,7 +120,6 @@ public class VideoActivity extends Activity {
122 120  
123 121 public void buffer()
124 122 {
125   - buffering = true;
126 123 toggleBuffering(true);
127 124 video.suspend();
128 125 }
... ... @@ -187,9 +184,13 @@ public class VideoActivity extends Activity {
187 184 }
188 185 catch (MalformedURLException e)
189 186 {
190   - e.printStackTrace();
  187 + Toast.makeText(this, "URL malformada", Toast.LENGTH_LONG).show();
191 188 }
192 189 }
  190 + public void showNotFound(String url)
  191 + {
  192 + Toast.makeText(this, "No s'ha trobat el segment " + url, Toast.LENGTH_LONG).show();
  193 + }
193 194  
194 195 @Override
195 196 public void onConfigurationChanged(Configuration newConfig) {
... ... @@ -202,11 +203,13 @@ public class VideoActivity extends Activity {
202 203 {
203 204 final static String TAG = "DescarregaSegment";
204 205 private long bps;
  206 + boolean failed;
  207 + String url;
205 208  
206 209 public DescarregaSegment()
207 210 {
208 211 bps = 0;
209   - pd = null;
  212 + failed = false;
210 213 }
211 214  
212 215 @Override
... ... @@ -248,8 +251,9 @@ public class VideoActivity extends Activity {
248 251 }
249 252 catch(IOException e)
250 253 {
  254 + url = urls[0].toString();
  255 + failed = true;
251 256 this.cancel(true);
252   - Toast.makeText(VideoActivity.this, e.getMessage(), Toast.LENGTH_LONG).show();
253 257 return null;
254 258 }
255 259 return null;
... ... @@ -260,10 +264,13 @@ public class VideoActivity extends Activity {
260 264 {
261 265 return;
262 266 }
263   -
264   - if(!queue.isEmpty() && buffering)
  267 + if(failed)
  268 + {
  269 + failed = false;
  270 + showNotFound(url);
  271 + }
  272 + else if(!queue.isEmpty() && buffering)
265 273 {
266   - buffering = false;
267 274 play(queue.get(0));
268 275 }
269 276 String newSegment = null;
... ...