Commit 79028e924d63f0780b573435fe7dff91f7b957aa

Authored by Imanol-Mikel Barba Sabariego
1 parent c62adcbf

--no commit message

res/values/strings.xml
... ... @@ -27,5 +27,17 @@
27 27 siusplau dirigeixi\'s a la Universitat o escrigui un mail als desenvolupadors.\n\n Necessària la instal·lació
28 28 de la llibreria Vitamio per reproduïr arxius .ts</string>
29 29 <string name="defaultURL">imanolbarba.myftp.biz/PBE</string>
  30 + <string name="qual">Quality</string>
  31 + <string name="qual_hint">Which is the default quality?</string>
  32 + <string-array name="qualityNames">
  33 + <item >High Quality</item>
  34 + <item >Medium Quality</item>
  35 + <item >Low Quality</item>
  36 + </string-array>
  37 + <string-array name="qualityValues">
  38 + <item >0</item>
  39 + <item >1</item>
  40 + <item >2</item>
  41 + </string-array>
30 42  
31 43 </resources>
32 44 \ No newline at end of file
... ...
res/xml/prefs.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
3 3 <EditTextPreference android:key="server" android:title="@string/url" android:summary="@string/urlhint" android:defaultValue="@string/defaultURL"/>
  4 + <ListPreference android:title="@string/qual" android:summary="@string/qual_hint" android:key="quality" android:entries="@array/qualityNames" android:entryValues="@array/qualityValues"/>
4 5 </PreferenceScreen>
5 6 \ No newline at end of file
... ...
src/com/upc/pbe/upcnews/HLS.java
... ... @@ -3,12 +3,11 @@ package com.upc.pbe.upcnews;
3 3 import java.io.File;
4 4 import java.io.IOException;
5 5 import java.util.ArrayList;
6   -
7 6 import android.net.TrafficStats;
8 7 import android.util.Log;
9 8  
10 9 //Gestor del protocol HTTP Live Streaming
11   -public class HLS {
  10 +public class HLS extends UpcApp{
12 11  
13 12 private static final String TAG = "HLS";
14 13 private ArrayList<ParentList> videos;
... ... @@ -31,6 +30,8 @@ public class HLS {
31 30 Log.d(TAG, "Deleted " + files[i].toString());
32 31 deleteme.delete();
33 32 }
  33 +
  34 + currentQuality = this.getQuality();
34 35 currentVideo = currentQuality = currentSegment = 0;
35 36 this.videos = parsed;
36 37 endReached = false;
... ...
src/com/upc/pbe/upcnews/UpcApp.java
... ... @@ -8,57 +8,63 @@ import android.preference.PreferenceManager;
8 8 import android.util.Log;
9 9  
10 10 //Instanciacio de la nostra aplicacio
11   -public class UpcApp extends Application implements OnSharedPreferenceChangeListener {
  11 +public class UpcApp extends Application implements
  12 + OnSharedPreferenceChangeListener {
12 13  
13 14 final static String TAG = "Application";
14   - private SharedPreferences prefs; //Conjunt de preferencies de l'aplicacio
15   - private String url = null;
  15 + private SharedPreferences prefs; // Conjunt de preferencies de l'aplicacio
  16 + private String url = null;
16 17 private String desc;
17   - private final static String localPath = Environment.getExternalStorageDirectory().getPath() + "/UPC NEWS/";
  18 + private final static String localPath = Environment
  19 + .getExternalStorageDirectory().getPath() + "/UPC NEWS/";
18 20 private HLS h;
19   -
20   - public String getLocalPath(){
  21 +
  22 + public String getLocalPath() {
21 23 return localPath;
22 24 }
23   -
24   - public HLS getHLS()
25   - {
  25 +
  26 + public HLS getHLS() {
26 27 return h;
27 28 }
28   -
29   - public void setHLS(HLS h)
30   - {
  29 +
  30 + public void setHLS(HLS h) {
31 31 this.h = h;
32 32 }
33   -
  33 +
34 34 public String getUrl() {
35   - url = "http://" + prefs.getString("server", getString(R.string.defaultURL));
  35 + url = "http://"
  36 + + prefs.getString("server", getString(R.string.defaultURL));
36 37 return url;
37 38 }
38 39  
39   -
40 40 public void onCreate() {
41 41 super.onCreate();
42   - //Prefs
43   - prefs = PreferenceManager.getDefaultSharedPreferences(this);
  42 + // Prefs
  43 + prefs = PreferenceManager.getDefaultSharedPreferences(this);
44 44 prefs.registerOnSharedPreferenceChangeListener(this);
45 45 this.getUrl();
46 46 Log.d(TAG, "onCreated");
47 47 }
48   -
  48 +
49 49 public SharedPreferences getPrefs() {
50 50 return prefs;
51 51 }
52 52  
53 53 public void onSharedPreferenceChanged(SharedPreferences arg0, String key) {
54   - Log.d(TAG, "onSharedPreferenceChanged for key: " + key);
  54 + Log.d(TAG, "onSharedPreferenceChanged for key: " + key);
55 55 }
56   -
57   - public void setDesc(String s){
  56 +
  57 + public void setDesc(String s) {
58 58 desc = s;
59 59 }
60   -
61   - public String getDesc(){
  60 +
  61 + public String getDesc() {
62 62 return desc;
63 63 }
  64 +
  65 + public int getQuality() {
  66 + int qual = Integer.parseInt(prefs.getString("quality", "0"));
  67 +
  68 + return qual;
  69 + }
64 70 }
65 71 \ No newline at end of file
... ...