Commit 79028e924d63f0780b573435fe7dff91f7b957aa
1 parent
c62adcbf
--no commit message
Showing
4 changed files
with
45 additions
and
25 deletions
res/values/strings.xml
@@ -27,5 +27,17 @@ | @@ -27,5 +27,17 @@ | ||
27 | siusplau dirigeixi\'s a la Universitat o escrigui un mail als desenvolupadors.\n\n Necessària la instal·lació | 27 | siusplau dirigeixi\'s a la Universitat o escrigui un mail als desenvolupadors.\n\n Necessària la instal·lació |
28 | de la llibreria Vitamio per reproduïr arxius .ts</string> | 28 | de la llibreria Vitamio per reproduïr arxius .ts</string> |
29 | <string name="defaultURL">imanolbarba.myftp.biz/PBE</string> | 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 | </resources> | 43 | </resources> |
32 | \ No newline at end of file | 44 | \ No newline at end of file |
res/xml/prefs.xml
1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
2 | <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > | 2 | <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > |
3 | <EditTextPreference android:key="server" android:title="@string/url" android:summary="@string/urlhint" android:defaultValue="@string/defaultURL"/> | 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 | </PreferenceScreen> | 5 | </PreferenceScreen> |
5 | \ No newline at end of file | 6 | \ No newline at end of file |
src/com/upc/pbe/upcnews/HLS.java
@@ -3,12 +3,11 @@ package com.upc.pbe.upcnews; | @@ -3,12 +3,11 @@ package com.upc.pbe.upcnews; | ||
3 | import java.io.File; | 3 | import java.io.File; |
4 | import java.io.IOException; | 4 | import java.io.IOException; |
5 | import java.util.ArrayList; | 5 | import java.util.ArrayList; |
6 | - | ||
7 | import android.net.TrafficStats; | 6 | import android.net.TrafficStats; |
8 | import android.util.Log; | 7 | import android.util.Log; |
9 | 8 | ||
10 | //Gestor del protocol HTTP Live Streaming | 9 | //Gestor del protocol HTTP Live Streaming |
11 | -public class HLS { | 10 | +public class HLS extends UpcApp{ |
12 | 11 | ||
13 | private static final String TAG = "HLS"; | 12 | private static final String TAG = "HLS"; |
14 | private ArrayList<ParentList> videos; | 13 | private ArrayList<ParentList> videos; |
@@ -31,6 +30,8 @@ public class HLS { | @@ -31,6 +30,8 @@ public class HLS { | ||
31 | Log.d(TAG, "Deleted " + files[i].toString()); | 30 | Log.d(TAG, "Deleted " + files[i].toString()); |
32 | deleteme.delete(); | 31 | deleteme.delete(); |
33 | } | 32 | } |
33 | + | ||
34 | + currentQuality = this.getQuality(); | ||
34 | currentVideo = currentQuality = currentSegment = 0; | 35 | currentVideo = currentQuality = currentSegment = 0; |
35 | this.videos = parsed; | 36 | this.videos = parsed; |
36 | endReached = false; | 37 | endReached = false; |
src/com/upc/pbe/upcnews/UpcApp.java
@@ -8,57 +8,63 @@ import android.preference.PreferenceManager; | @@ -8,57 +8,63 @@ import android.preference.PreferenceManager; | ||
8 | import android.util.Log; | 8 | import android.util.Log; |
9 | 9 | ||
10 | //Instanciacio de la nostra aplicacio | 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 | final static String TAG = "Application"; | 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 | private String desc; | 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 | private HLS h; | 20 | private HLS h; |
19 | - | ||
20 | - public String getLocalPath(){ | 21 | + |
22 | + public String getLocalPath() { | ||
21 | return localPath; | 23 | return localPath; |
22 | } | 24 | } |
23 | - | ||
24 | - public HLS getHLS() | ||
25 | - { | 25 | + |
26 | + public HLS getHLS() { | ||
26 | return h; | 27 | return h; |
27 | } | 28 | } |
28 | - | ||
29 | - public void setHLS(HLS h) | ||
30 | - { | 29 | + |
30 | + public void setHLS(HLS h) { | ||
31 | this.h = h; | 31 | this.h = h; |
32 | } | 32 | } |
33 | - | 33 | + |
34 | public String getUrl() { | 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 | return url; | 37 | return url; |
37 | } | 38 | } |
38 | 39 | ||
39 | - | ||
40 | public void onCreate() { | 40 | public void onCreate() { |
41 | super.onCreate(); | 41 | super.onCreate(); |
42 | - //Prefs | ||
43 | - prefs = PreferenceManager.getDefaultSharedPreferences(this); | 42 | + // Prefs |
43 | + prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
44 | prefs.registerOnSharedPreferenceChangeListener(this); | 44 | prefs.registerOnSharedPreferenceChangeListener(this); |
45 | this.getUrl(); | 45 | this.getUrl(); |
46 | Log.d(TAG, "onCreated"); | 46 | Log.d(TAG, "onCreated"); |
47 | } | 47 | } |
48 | - | 48 | + |
49 | public SharedPreferences getPrefs() { | 49 | public SharedPreferences getPrefs() { |
50 | return prefs; | 50 | return prefs; |
51 | } | 51 | } |
52 | 52 | ||
53 | public void onSharedPreferenceChanged(SharedPreferences arg0, String key) { | 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 | desc = s; | 58 | desc = s; |
59 | } | 59 | } |
60 | - | ||
61 | - public String getDesc(){ | 60 | + |
61 | + public String getDesc() { | ||
62 | return desc; | 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 | \ No newline at end of file | 71 | \ No newline at end of file |