Commit e0c3f3a00bb392e335d117eafcb6a96d39868970
1 parent
50c012ea
Bugs con rutas y progressDialog fixed
Showing
3 changed files
with
30 additions
and
24 deletions
src/com/upc/pbe/upcnews/HLS.java
1 | package com.upc.pbe.upcnews; | 1 | package com.upc.pbe.upcnews; |
2 | 2 | ||
3 | import java.io.File; | 3 | import java.io.File; |
4 | -import java.io.IOException; | ||
5 | import java.util.ArrayList; | 4 | import java.util.ArrayList; |
6 | 5 | ||
7 | import android.util.Log; | 6 | import android.util.Log; |
@@ -47,7 +46,7 @@ public class HLS | @@ -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 | // Determina la seguent qualitat a partir de la velocitat | 51 | // Determina la seguent qualitat a partir de la velocitat |
53 | if (currentSegment == segments.size()) | 52 | if (currentSegment == segments.size()) |
src/com/upc/pbe/upcnews/Parser.java
@@ -496,7 +496,7 @@ public class Parser | @@ -496,7 +496,7 @@ public class Parser | ||
496 | } | 496 | } |
497 | else if (line.startsWith("/")) | 497 | else if (line.startsWith("/")) |
498 | { | 498 | { |
499 | - line = server + line; | 499 | + line = "http://" + server + line; |
500 | } | 500 | } |
501 | pls.getSegments().get(currentSegment).setURL(line); | 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,30 +86,28 @@ public class VideoActivity extends Activity { | ||
86 | downloadSegment(getNext()); | 86 | downloadSegment(getNext()); |
87 | } | 87 | } |
88 | 88 | ||
89 | - public String getNext() { | ||
90 | - try { | 89 | + public String getNext() |
90 | + { | ||
91 | return h.next(); | 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 | public void toggleBuffering(boolean b) | 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 | pd.show(); | 105 | pd.show(); |
108 | } | 106 | } |
109 | - else if(pd != null) | 107 | + else |
110 | { | 108 | { |
109 | + buffering = false; | ||
111 | pd.dismiss(); | 110 | pd.dismiss(); |
112 | - pd = null; | ||
113 | } | 111 | } |
114 | } | 112 | } |
115 | 113 | ||
@@ -122,7 +120,6 @@ public class VideoActivity extends Activity { | @@ -122,7 +120,6 @@ public class VideoActivity extends Activity { | ||
122 | 120 | ||
123 | public void buffer() | 121 | public void buffer() |
124 | { | 122 | { |
125 | - buffering = true; | ||
126 | toggleBuffering(true); | 123 | toggleBuffering(true); |
127 | video.suspend(); | 124 | video.suspend(); |
128 | } | 125 | } |
@@ -187,9 +184,13 @@ public class VideoActivity extends Activity { | @@ -187,9 +184,13 @@ public class VideoActivity extends Activity { | ||
187 | } | 184 | } |
188 | catch (MalformedURLException e) | 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 | @Override | 195 | @Override |
195 | public void onConfigurationChanged(Configuration newConfig) { | 196 | public void onConfigurationChanged(Configuration newConfig) { |
@@ -202,11 +203,13 @@ public class VideoActivity extends Activity { | @@ -202,11 +203,13 @@ public class VideoActivity extends Activity { | ||
202 | { | 203 | { |
203 | final static String TAG = "DescarregaSegment"; | 204 | final static String TAG = "DescarregaSegment"; |
204 | private long bps; | 205 | private long bps; |
206 | + boolean failed; | ||
207 | + String url; | ||
205 | 208 | ||
206 | public DescarregaSegment() | 209 | public DescarregaSegment() |
207 | { | 210 | { |
208 | bps = 0; | 211 | bps = 0; |
209 | - pd = null; | 212 | + failed = false; |
210 | } | 213 | } |
211 | 214 | ||
212 | @Override | 215 | @Override |
@@ -248,8 +251,9 @@ public class VideoActivity extends Activity { | @@ -248,8 +251,9 @@ public class VideoActivity extends Activity { | ||
248 | } | 251 | } |
249 | catch(IOException e) | 252 | catch(IOException e) |
250 | { | 253 | { |
254 | + url = urls[0].toString(); | ||
255 | + failed = true; | ||
251 | this.cancel(true); | 256 | this.cancel(true); |
252 | - Toast.makeText(VideoActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); | ||
253 | return null; | 257 | return null; |
254 | } | 258 | } |
255 | return null; | 259 | return null; |
@@ -260,10 +264,13 @@ public class VideoActivity extends Activity { | @@ -260,10 +264,13 @@ public class VideoActivity extends Activity { | ||
260 | { | 264 | { |
261 | return; | 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 | play(queue.get(0)); | 274 | play(queue.get(0)); |
268 | } | 275 | } |
269 | String newSegment = null; | 276 | String newSegment = null; |