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