Commit c71e1d9317f997a15325064090dbe3bfd437e7e9
1 parent
9d2a6958
--no commit message
Showing
5 changed files
with
136 additions
and
143 deletions
gen/com/upc/pbe/upcnews/R.java
1 | -/* AUTO-GENERATED FILE. DO NOT MODIFY. | |
2 | - * | |
3 | - * This class was automatically generated by the | |
4 | - * aapt tool from the resource data it found. It | |
5 | - * should not be modified by hand. | |
6 | - */ | |
7 | - | |
8 | -package com.upc.pbe.upcnews; | |
9 | - | |
10 | -public final class R { | |
11 | - public static final class attr { | |
12 | - } | |
13 | - public static final class color { | |
14 | - public static final int Black=0x7f050002; | |
15 | - public static final int Blue=0x7f050004; | |
16 | - public static final int BlueAndroid=0x7f050005; | |
17 | - public static final int Gay=0x7f050007; | |
18 | - public static final int Gray=0x7f05000a; | |
19 | - public static final int Green=0x7f050009; | |
20 | - public static final int Orange=0x7f050003; | |
21 | - public static final int Red=0x7f050008; | |
22 | - public static final int White=0x7f050006; | |
23 | - public static final int Whyte_POwaH=0x7f050001; | |
24 | - public static final int backgroundmain=0x7f050000; | |
25 | - } | |
26 | - public static final class dimen { | |
27 | - public static final int TitleSize=0x7f060000; | |
28 | - public static final int lesize=0x7f060001; | |
29 | - } | |
30 | - public static final class drawable { | |
31 | - public static final int ic_action_search=0x7f020000; | |
32 | - public static final int ic_launcher=0x7f020001; | |
33 | - public static final int ic_ledarklogo=0x7f020002; | |
34 | - public static final int ic_menu_name=0x7f020003; | |
35 | - public static final int ic_startbutton=0x7f020004; | |
36 | - public static final int selectedonlist=0x7f020005; | |
37 | - public static final int selectedonlist2=0x7f020006; | |
38 | - public static final int startbuttontoggle=0x7f020007; | |
39 | - } | |
40 | - public static final class id { | |
41 | - public static final int LinearLayout1=0x7f0a0001; | |
42 | - public static final int RelativeLayout1=0x7f0a0006; | |
43 | - public static final int button=0x7f0a0007; | |
44 | - public static final int itemhelp=0x7f0a000d; | |
45 | - public static final int itemprefs=0x7f0a000c; | |
46 | - public static final int listView1=0x7f0a0003; | |
47 | - public static final int menu_settings=0x7f0a000b; | |
48 | - public static final int rowTextView=0x7f0a000a; | |
49 | - public static final int textView1=0x7f0a0004; | |
50 | - public static final int textView2=0x7f0a0005; | |
51 | - public static final int textViewTitle=0x7f0a0002; | |
52 | - public static final int textViewUrl=0x7f0a0009; | |
53 | - public static final int textViewXml=0x7f0a0008; | |
54 | - public static final int videoView1=0x7f0a0000; | |
55 | - } | |
56 | - public static final class layout { | |
57 | - public static final int activity_video=0x7f030000; | |
58 | - public static final int dirs=0x7f030001; | |
59 | - public static final int help=0x7f030002; | |
60 | - public static final int main_activity=0x7f030003; | |
61 | - public static final int rowlayout=0x7f030004; | |
62 | - } | |
63 | - public static final class menu { | |
64 | - public static final int activity_main=0x7f090000; | |
65 | - public static final int activity_video=0x7f090001; | |
66 | - public static final int menu=0x7f090002; | |
67 | - } | |
68 | - public static final class string { | |
69 | - public static final int app_name=0x7f070000; | |
70 | - public static final int button=0x7f07000c; | |
71 | - public static final int button1=0x7f07000d; | |
72 | - public static final int defaultURL=0x7f070013; | |
73 | - public static final int desc=0x7f070009; | |
74 | - public static final int descarregar=0x7f070003; | |
75 | - public static final int dir=0x7f07000a; | |
76 | - public static final int directoris=0x7f07000b; | |
77 | - public static final int hello_world=0x7f070010; | |
78 | - public static final int help=0x7f070008; | |
79 | - public static final int helpText=0x7f070012; | |
80 | - public static final int hint=0x7f070004; | |
81 | - public static final int menu_settings=0x7f070001; | |
82 | - public static final int prefs=0x7f070007; | |
83 | - public static final int startbuttondescription=0x7f07000f; | |
84 | - public static final int title=0x7f07000e; | |
85 | - public static final int title_activity_main=0x7f070002; | |
86 | - public static final int title_activity_video=0x7f070011; | |
87 | - public static final int url=0x7f070005; | |
88 | - public static final int urlhint=0x7f070006; | |
89 | - } | |
90 | - public static final class style { | |
91 | - public static final int AppTheme=0x7f080000; | |
92 | - public static final int leBoldText=0x7f080001; | |
93 | - } | |
94 | - public static final class xml { | |
95 | - public static final int prefs=0x7f040000; | |
96 | - } | |
97 | -} | |
1 | +/* AUTO-GENERATED FILE. DO NOT MODIFY. | |
2 | + * | |
3 | + * This class was automatically generated by the | |
4 | + * aapt tool from the resource data it found. It | |
5 | + * should not be modified by hand. | |
6 | + */ | |
7 | + | |
8 | +package com.upc.pbe.upcnews; | |
9 | + | |
10 | +public final class R { | |
11 | + public static final class attr { | |
12 | + } | |
13 | + public static final class color { | |
14 | + public static final int Black=0x7f050002; | |
15 | + public static final int Blue=0x7f050004; | |
16 | + public static final int BlueAndroid=0x7f050005; | |
17 | + public static final int Gay=0x7f050007; | |
18 | + public static final int Gray=0x7f05000a; | |
19 | + public static final int Green=0x7f050009; | |
20 | + public static final int Orange=0x7f050003; | |
21 | + public static final int Red=0x7f050008; | |
22 | + public static final int White=0x7f050006; | |
23 | + public static final int Whyte_POwaH=0x7f050001; | |
24 | + public static final int backgroundmain=0x7f050000; | |
25 | + } | |
26 | + public static final class dimen { | |
27 | + public static final int TitleSize=0x7f060000; | |
28 | + public static final int lesize=0x7f060001; | |
29 | + } | |
30 | + public static final class drawable { | |
31 | + public static final int ic_action_search=0x7f020000; | |
32 | + public static final int ic_launcher=0x7f020001; | |
33 | + public static final int ic_ledarklogo=0x7f020002; | |
34 | + public static final int ic_menu_name=0x7f020003; | |
35 | + public static final int ic_startbutton=0x7f020004; | |
36 | + public static final int selectedonlist=0x7f020005; | |
37 | + public static final int selectedonlist2=0x7f020006; | |
38 | + public static final int startbuttontoggle=0x7f020007; | |
39 | + } | |
40 | + public static final class id { | |
41 | + public static final int LinearLayout1=0x7f0a0001; | |
42 | + public static final int RelativeLayout1=0x7f0a0006; | |
43 | + public static final int button=0x7f0a0007; | |
44 | + public static final int itemhelp=0x7f0a000d; | |
45 | + public static final int itemprefs=0x7f0a000c; | |
46 | + public static final int listView1=0x7f0a0003; | |
47 | + public static final int menu_settings=0x7f0a000b; | |
48 | + public static final int rowTextView=0x7f0a000a; | |
49 | + public static final int textView1=0x7f0a0004; | |
50 | + public static final int textView2=0x7f0a0005; | |
51 | + public static final int textViewTitle=0x7f0a0002; | |
52 | + public static final int textViewUrl=0x7f0a0009; | |
53 | + public static final int textViewXml=0x7f0a0008; | |
54 | + public static final int videoView1=0x7f0a0000; | |
55 | + } | |
56 | + public static final class layout { | |
57 | + public static final int activity_video=0x7f030000; | |
58 | + public static final int dirs=0x7f030001; | |
59 | + public static final int help=0x7f030002; | |
60 | + public static final int main_activity=0x7f030003; | |
61 | + public static final int rowlayout=0x7f030004; | |
62 | + } | |
63 | + public static final class menu { | |
64 | + public static final int activity_main=0x7f090000; | |
65 | + public static final int activity_video=0x7f090001; | |
66 | + public static final int menu=0x7f090002; | |
67 | + } | |
68 | + public static final class string { | |
69 | + public static final int app_name=0x7f070000; | |
70 | + public static final int button=0x7f07000c; | |
71 | + public static final int button1=0x7f07000d; | |
72 | + public static final int defaultURL=0x7f070013; | |
73 | + public static final int desc=0x7f070009; | |
74 | + public static final int descarregar=0x7f070003; | |
75 | + public static final int dir=0x7f07000a; | |
76 | + public static final int directoris=0x7f07000b; | |
77 | + public static final int hello_world=0x7f070010; | |
78 | + public static final int help=0x7f070008; | |
79 | + public static final int helpText=0x7f070012; | |
80 | + public static final int hint=0x7f070004; | |
81 | + public static final int menu_settings=0x7f070001; | |
82 | + public static final int prefs=0x7f070007; | |
83 | + public static final int startbuttondescription=0x7f07000f; | |
84 | + public static final int title=0x7f07000e; | |
85 | + public static final int title_activity_main=0x7f070002; | |
86 | + public static final int title_activity_video=0x7f070011; | |
87 | + public static final int url=0x7f070005; | |
88 | + public static final int urlhint=0x7f070006; | |
89 | + } | |
90 | + public static final class style { | |
91 | + public static final int AppTheme=0x7f080000; | |
92 | + public static final int leBoldText=0x7f080001; | |
93 | + } | |
94 | + public static final class xml { | |
95 | + public static final int prefs=0x7f040000; | |
96 | + } | |
97 | +} | ... | ... |
src/com/upc/pbe/upcnews/Directoris.java
... | ... | @@ -63,25 +63,27 @@ public class Directoris extends Activity implements OnItemClickListener { |
63 | 63 | public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
64 | 64 | //Determina el funcionament al clickar en una de les entrades de al ListView |
65 | 65 | String path = ((TextView)view).getText().toString(); |
66 | - //Si es un m3u8, el descarrega, parseja i inicia la reproducci� | |
66 | + //Si es un m3u8, el descarrega, parseja i inicia la reproduccio | |
67 | 67 | if(path.endsWith(".m3u8")){ |
68 | 68 | path = currentFolder + path; |
69 | 69 | String playlist; |
70 | 70 | try{ |
71 | + //Descarreguem m3u8 | |
71 | 72 | playlist = d.doInBackground(path); |
72 | 73 | Parser p = new Parser(path.substring(0, path.lastIndexOf("/") + 1), this); |
73 | 74 | try{ |
75 | + //Parsing m3u8 | |
74 | 76 | ArrayList<ParentList> m3u8parsed = p.parseFile(playlist); |
75 | - Log.d(TAG, "parsing completed"); | |
77 | + Log.d(TAG, "Parsing completat"); | |
78 | + //Creem un gestor HLS | |
76 | 79 | HLS h = new HLS(m3u8parsed,((UpcApp)getApplication()).getLocalPath()); |
77 | 80 | ((UpcApp)getApplication()).setHLS(h); |
81 | + //Iniciem la reproduccio | |
78 | 82 | Intent mIntent = new Intent(this, VideoActivity.class); |
79 | - if(((UpcApp)getApplication()).getHLS() != null) | |
80 | - { | |
83 | + if(((UpcApp)getApplication()).getHLS() != null) { | |
81 | 84 | startActivity(mIntent); |
82 | 85 | } |
83 | - else | |
84 | - { | |
86 | + else { | |
85 | 87 | Toast.makeText(this, "HLS engine error", Toast.LENGTH_LONG).show(); |
86 | 88 | } |
87 | 89 | } | ... | ... |
src/com/upc/pbe/upcnews/HLS.java
... | ... | @@ -8,8 +8,8 @@ import android.net.TrafficStats; |
8 | 8 | import android.util.Log; |
9 | 9 | |
10 | 10 | //Gestor del protocol HTTP Live Streaming |
11 | -public class HLS | |
12 | -{ | |
11 | +public class HLS { | |
12 | + | |
13 | 13 | private static final String TAG = "HLS"; |
14 | 14 | private ArrayList<ParentList> videos; |
15 | 15 | private ArrayList<Segment> segments; |
... | ... | @@ -22,15 +22,11 @@ public class HLS |
22 | 22 | private Descarrega d; |
23 | 23 | private BandwidthMeasurer bm; |
24 | 24 | |
25 | - public HLS(ArrayList<ParentList> parsed, String localFolder) | |
26 | - { | |
27 | - /* | |
28 | - * CLEAN DIRECTORY | |
29 | - */ | |
25 | + public HLS(ArrayList<ParentList> parsed, String localFolder) { | |
26 | + //Neteja el directori i inicialitza les variables | |
30 | 27 | File dir = new File(localFolder); |
31 | 28 | String[] files = dir.list(); |
32 | - for (int i = 0; i < files.length; i++) | |
33 | - { | |
29 | + for (int i = 0; i < files.length; i++) { | |
34 | 30 | File deleteme = new File(dir, files[i]); |
35 | 31 | Log.d(TAG, "Deleted " + files[i].toString()); |
36 | 32 | deleteme.delete(); |
... | ... | @@ -43,22 +39,19 @@ public class HLS |
43 | 39 | d = new Descarrega(); |
44 | 40 | } |
45 | 41 | |
46 | - public void loadVideo() | |
47 | - { | |
42 | + public void loadVideo() { | |
43 | + //Carrega la seguent qualitat i, a partir d'aixo, el seguent segment | |
48 | 44 | qualities = videos.get(currentVideo++).getLists(); |
49 | 45 | segments = qualities.get(currentQuality).getSegments(); |
50 | - if (currentVideo == videos.size()) | |
51 | - { | |
46 | + if (currentVideo == videos.size()) { | |
52 | 47 | endReached = true; |
53 | 48 | } |
54 | 49 | } |
55 | 50 | |
56 | - public String next() throws IOException | |
57 | - { | |
58 | - if(currentSegment == segments.size()) | |
59 | - { | |
60 | - if(endReached) | |
61 | - { | |
51 | + public String next() throws IOException { | |
52 | + //Determina la seguent qualitat a partir de la velocitat | |
53 | + if(currentSegment == segments.size()) { | |
54 | + if(endReached) { | |
62 | 55 | return null; |
63 | 56 | } |
64 | 57 | loadVideo(); |
... | ... | @@ -70,8 +63,7 @@ public class HLS |
70 | 63 | d.descarregarguardar(seg.getURL(),localFolder); |
71 | 64 | double bps = bm.Measure(segmentBytes,startTime); |
72 | 65 | Log.d(TAG, "Current KB/s: " + (bps/8e3)); |
73 | - if((bps < qualities.get(currentQuality).getQuality()) && (bps != -1)) | |
74 | - { | |
66 | + if((bps < qualities.get(currentQuality).getQuality()) && (bps != -1)) { | |
75 | 67 | currentQuality++; |
76 | 68 | } |
77 | 69 | return localFolder + seg.getURL().substring(seg.getURL().lastIndexOf("/")+1, seg.getURL().length()); | ... | ... |
src/com/upc/pbe/upcnews/MainActivity.java
... | ... | @@ -30,7 +30,7 @@ public class MainActivity extends Activity implements OnClickListener { |
30 | 30 | super.onCreate(savedInstanceState); |
31 | 31 | setContentView(R.layout.main_activity); |
32 | 32 | Log.d(TAG, "onCreated"); |
33 | - //Especifiquem la ruta de desc�rrega | |
33 | + //Especifiquem la ruta de descarrega | |
34 | 34 | File tempFolder = new File(((UpcApp)getApplication()).getLocalPath()); |
35 | 35 | if(tempFolder.mkdirs()) |
36 | 36 | { | ... | ... |
src/com/upc/pbe/upcnews/VideoActivity.java
... | ... | @@ -12,33 +12,34 @@ import android.widget.MediaController; |
12 | 12 | import android.widget.Toast; |
13 | 13 | import android.widget.VideoView; |
14 | 14 | |
15 | -public class VideoActivity extends Activity | |
16 | -{ | |
15 | +//Tercera activitat principal, executa la reproduccio del video sencer | |
16 | +public class VideoActivity extends Activity { | |
17 | + | |
18 | + private final static String TAG = "VideoActivity"; | |
17 | 19 | private VideoView video; |
18 | 20 | private HLS h; |
19 | - private final static String TAG = "VideoActivity"; | |
20 | 21 | |
21 | 22 | @Override |
22 | 23 | public void onCreate(Bundle savedInstanceState) { |
24 | + //Creem el layout | |
23 | 25 | super.onCreate(savedInstanceState); |
24 | 26 | setContentView(R.layout.activity_video); |
25 | 27 | video = (VideoView) findViewById(R.id.videoView1); |
26 | - video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() | |
27 | - { | |
28 | - public void onCompletion(MediaPlayer mp) | |
29 | - { | |
28 | + //Creem un listener associat al fi de l'activitat (el fi de cada ts) | |
29 | + video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() { | |
30 | + public void onCompletion(MediaPlayer mp) { | |
31 | + //Al acabar cada ts, reproduit el seguent | |
30 | 32 | playNext(); |
31 | 33 | } |
32 | 34 | }); |
35 | + //Creem un gestor HLS, carreguem el video i iniciem la reproduccio | |
33 | 36 | h = ((UpcApp)getApplication()).getHLS(); |
34 | 37 | h.loadVideo(); |
35 | 38 | playNext(); |
36 | 39 | } |
37 | 40 | |
38 | - public void play(String url) | |
39 | - { | |
40 | - if(url == null) | |
41 | - { | |
41 | + public void play(String url) { | |
42 | + if(url == null) { | |
42 | 43 | super.finish(); |
43 | 44 | return; |
44 | 45 | } |
... | ... | @@ -49,16 +50,13 @@ public class VideoActivity extends Activity |
49 | 50 | video.requestFocus(); |
50 | 51 | } |
51 | 52 | |
52 | - public void playNext() | |
53 | - { | |
54 | - try | |
55 | - { | |
53 | + public void playNext() { | |
54 | + try { | |
56 | 55 | String next = h.next(); |
57 | 56 | play(next); |
58 | 57 | } |
59 | - catch(IOException e) | |
60 | - { | |
61 | - Toast.makeText(this, "Can't find segment", Toast.LENGTH_LONG).show(); | |
58 | + catch(IOException e) { | |
59 | + Toast.makeText(this, "No s'ha trobat el segment", Toast.LENGTH_LONG).show(); | |
62 | 60 | super.finish(); |
63 | 61 | return; |
64 | 62 | } |
... | ... | @@ -66,6 +64,7 @@ public class VideoActivity extends Activity |
66 | 64 | |
67 | 65 | @Override |
68 | 66 | public boolean onCreateOptionsMenu(Menu menu) { |
67 | + //Determina el funcionament al apretar la tecla d'opcions | |
69 | 68 | getMenuInflater().inflate(R.menu.activity_video, menu); |
70 | 69 | return true; |
71 | 70 | } | ... | ... |