Commit 7fc4ab60caab97dcaa7c931ff5495148642fa646

Authored by Imanol-Mikel Barba Sabariego
1 parent 9d5699cc

Reproductor y controles hechos

AndroidManifest.xml
... ... @@ -10,8 +10,6 @@
10 10 <uses-permission android:name="android.permission.INTERNET" />
11 11 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
12 12  
13   - <uses-feature android:name="android.hardware.wifi" />
14   -
15 13 <application
16 14 android:name=".UpcApp"
17 15 android:icon="@drawable/ic_launcher"
... ... @@ -32,11 +30,11 @@
32 30 </activity>
33 31 <activity android:name=".Help" >
34 32 </activity>
35   - <activity android:name=".Directoris" >
  33 + <activity android:name=".Directoris" >
36 34 </activity>
37   - <activity android:name=".VideoActivity" >
  35 + <activity android:name=".VideoActivity" android:theme="@style/FullScreen" android:configChanges="orientation">
38 36 </activity>
39   - <activity
  37 + <activity
40 38 android:name="io.vov.vitamio.activity.InitActivity"
41 39 android:launchMode="singleTop"
42 40 android:theme="@android:style/Theme.NoTitleBar"
... ...
VitamioBundle/bin/classes/io/vov/vitamio/R$drawable.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/R$id.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/R$layout.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/R$raw.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/R$string.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/R$style.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/widget/MediaController$1.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/widget/MediaController$2.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/widget/MediaController$3.class
No preview for this file type
VitamioBundle/bin/classes/io/vov/vitamio/widget/MediaController.class
No preview for this file type
VitamioBundle/bin/io.vov.vitamio.activity.initactivity.jar
No preview for this file type
VitamioBundle/lint.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<lint>
  3 +</lint>
0 4 \ No newline at end of file
... ...
VitamioBundle/project.properties
... ... @@ -11,5 +11,5 @@
11 11 #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
12 12  
13 13 # Project target.
14   -target=android-15
  14 +target=android-10
15 15 android.library=true
... ...
VitamioBundle/res/drawable-hdpi/mediacontroller_ff_left.png 0 → 100644

865 Bytes

VitamioBundle/res/drawable-hdpi/mediacontroller_ff_right.png 0 → 100644

860 Bytes

VitamioBundle/res/layout/mediacontroller.xml
1 1 <?xml version="1.0" encoding="utf-8"?>
2 2 <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3 android:layout_width="match_parent"
4   - android:layout_height="74dip"
  4 + android:layout_height="80dip"
5 5 android:layout_alignParentBottom="true"
6 6 android:layout_marginBottom="0.0dip"
7 7 android:layout_marginLeft="0.0dip"
... ... @@ -9,27 +9,13 @@
9 9 android:background="@drawable/mediacontroller_bg"
10 10 android:orientation="horizontal" >
11 11  
12   - <ImageButton
13   - android:id="@+id/mediacontroller_play_pause"
14   - android:layout_width="54.6dip"
15   - android:layout_height="32dip"
16   - android:layout_alignParentRight="true"
17   - android:layout_centerHorizontal="true"
18   - android:layout_centerVertical="true"
19   - android:layout_marginRight="7.0dip"
20   - android:background="#00000000"
21   - android:contentDescription="@string/mediacontroller_play_pause"
22   - android:gravity="center"
23   - android:src="@drawable/mediacontroller_pause_button" />
24   -
25 12 <RelativeLayout
26 13 android:layout_width="match_parent"
27 14 android:layout_height="wrap_content"
28 15 android:layout_marginBottom="2dip"
29 16 android:layout_marginLeft="7.0dip"
30 17 android:layout_marginRight="7.0dip"
31   - android:layout_marginTop="2dip"
32   - android:layout_toLeftOf="@+id/mediacontroller_play_pause" >
  18 + android:layout_marginTop="2dip" >
33 19  
34 20 <RelativeLayout
35 21 android:layout_width="match_parent"
... ... @@ -69,6 +55,42 @@
69 55 android:layout_alignParentBottom="true"
70 56 android:ellipsize="marquee"
71 57 android:singleLine="true" />
  58 +
72 59 </RelativeLayout>
73 60  
  61 + <ImageButton
  62 + android:id="@+id/mediacontroller_play_pause"
  63 + android:layout_width="54.6dip"
  64 + android:layout_height="32dip"
  65 + android:layout_alignParentBottom="true"
  66 + android:layout_centerHorizontal="true"
  67 + android:background="#00000000"
  68 + android:contentDescription="@string/mediacontroller_play_pause"
  69 + android:gravity="center"
  70 + android:src="@drawable/mediacontroller_pause_button" />
  71 +
  72 + <ImageButton
  73 + android:id="@+id/ImageButton01"
  74 + android:layout_width="54.6dip"
  75 + android:layout_height="32dip"
  76 + android:layout_alignParentBottom="true"
  77 + android:layout_marginRight="20dp"
  78 + android:layout_toLeftOf="@+id/mediacontroller_play_pause"
  79 + android:background="#00000000"
  80 + android:gravity="center"
  81 + android:scaleType="fitCenter"
  82 + android:src="@drawable/mediacontroller_ff_left" />
  83 +
  84 + <ImageButton
  85 + android:id="@+id/ImageButton02"
  86 + android:layout_width="54.6dip"
  87 + android:layout_height="32dip"
  88 + android:layout_alignParentBottom="true"
  89 + android:layout_marginLeft="14dp"
  90 + android:layout_toRightOf="@+id/mediacontroller_play_pause"
  91 + android:background="#00000000"
  92 + android:gravity="center"
  93 + android:scaleType="fitCenter"
  94 + android:src="@drawable/mediacontroller_ff_right" />
  95 +
74 96 </RelativeLayout>
75 97 \ No newline at end of file
... ...
VitamioBundle/src/io/vov/vitamio/widget/MediaController.java
... ... @@ -89,6 +89,9 @@ public class MediaController extends FrameLayout {
89 89 private static final int SHOW_PROGRESS = 2;
90 90 private boolean mFromXml = false;
91 91 private ImageButton mPauseButton;
  92 + private ImageButton mFFLeftButton;
  93 + private ImageButton mFFRightButton;
  94 +
92 95  
93 96 private AudioManager mAM;
94 97  
... ... @@ -156,10 +159,21 @@ public class MediaController extends FrameLayout {
156 159  
157 160 private void initControllerView(View v) {
158 161 mPauseButton = (ImageButton) v.findViewById(R.id.mediacontroller_play_pause);
  162 + mFFLeftButton = (ImageButton) v.findViewById(R.id.ImageButton01);
  163 + mFFRightButton = (ImageButton) v.findViewById(R.id.ImageButton02);
159 164 if (mPauseButton != null) {
160 165 mPauseButton.requestFocus();
161 166 mPauseButton.setOnClickListener(mPauseListener);
162 167 }
  168 + if (mFFLeftButton != null) {
  169 + mFFLeftButton.requestFocus();
  170 + mFFLeftButton.setOnClickListener(mFFLeftListener);
  171 + }
  172 + if (mFFRightButton != null) {
  173 + mFFRightButton.requestFocus();
  174 + mFFRightButton.setOnClickListener(mFFRightListener);
  175 + }
  176 +
163 177  
164 178 mProgress = (ProgressBar) v.findViewById(R.id.mediacontroller_seekbar);
165 179 if (mProgress != null) {
... ... @@ -196,6 +210,8 @@ public class MediaController extends FrameLayout {
196 210 public void show() {
197 211 show(sDefaultTimeout);
198 212 }
  213 +
  214 +
199 215  
200 216 /**
201 217 * Set the content of the file_name TextView
... ... @@ -258,6 +274,10 @@ public class MediaController extends FrameLayout {
258 274 if (!mShowing && mAnchor != null && mAnchor.getWindowToken() != null) {
259 275 if (mPauseButton != null)
260 276 mPauseButton.requestFocus();
  277 + if (mFFLeftButton != null)
  278 + mFFLeftButton.requestFocus();
  279 + if (mFFRightButton != null)
  280 + mFFRightButton.requestFocus();
261 281 disableUnsupportedButtons();
262 282  
263 283 if (mFromXml) {
... ... @@ -409,13 +429,40 @@ public class MediaController extends FrameLayout {
409 429 return super.dispatchKeyEvent(event);
410 430 }
411 431  
  432 + public void setOnFFLeftListener(View.OnClickListener ocl)
  433 + {
  434 + mFFLeftListener = ocl;
  435 + if (mFFLeftButton != null) {
  436 + mFFLeftButton.requestFocus();
  437 + mFFLeftButton.setOnClickListener(mFFLeftListener);
  438 + }
  439 + }
  440 + public void setOnFFRightListener(View.OnClickListener ocl)
  441 + {
  442 + mFFRightListener = ocl;
  443 + if (mFFRightButton != null) {
  444 + mFFRightButton.requestFocus();
  445 + mFFRightButton.setOnClickListener(mFFRightListener);
  446 + }
  447 + }
  448 +
412 449 private View.OnClickListener mPauseListener = new View.OnClickListener() {
413 450 public void onClick(View v) {
414 451 doPauseResume();
415 452 show(sDefaultTimeout);
416 453 }
417 454 };
  455 + private View.OnClickListener mFFLeftListener = new View.OnClickListener() {
  456 + public void onClick(View v) {
418 457  
  458 + }
  459 + };
  460 + private View.OnClickListener mFFRightListener = new View.OnClickListener() {
  461 + public void onClick(View v) {
  462 +
  463 + }
  464 + };
  465 +
419 466 private void updatePausePlay() {
420 467 if (mRoot == null || mPauseButton == null)
421 468 return;
... ... @@ -480,8 +527,13 @@ public class MediaController extends FrameLayout {
480 527 public void setEnabled(boolean enabled) {
481 528 if (mPauseButton != null)
482 529 mPauseButton.setEnabled(enabled);
483   - if (mProgress != null)
484   - mProgress.setEnabled(enabled);
  530 + if (mPauseButton != null)
  531 + mPauseButton.setEnabled(enabled);
  532 + if (mFFLeftButton != null)
  533 + mFFLeftButton.setEnabled(enabled);
  534 + if (mFFRightButton != null)
  535 + mFFRightButton.setEnabled(enabled);
  536 +
485 537 disableUnsupportedButtons();
486 538 super.setEnabled(enabled);
487 539 }
... ...
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 array {
12   - public static final int qualityNames=0x7f080000;
13   - public static final int qualityValues=0x7f080001;
14   - }
15   - public static final class attr {
16   - }
17   - public static final class color {
18   - public static final int Black=0x7f050002;
19   - public static final int Blue=0x7f050004;
20   - public static final int BlueAndroid=0x7f050005;
21   - public static final int Gay=0x7f050007;
22   - public static final int Gray=0x7f05000a;
23   - public static final int Green=0x7f050009;
24   - public static final int Orange=0x7f050003;
25   - public static final int Red=0x7f050008;
26   - public static final int White=0x7f050006;
27   - public static final int Whyte_POwaH=0x7f050001;
28   - public static final int backgroundmain=0x7f050000;
29   - }
30   - public static final class dimen {
31   - public static final int TitleSize=0x7f060000;
32   - public static final int lesize=0x7f060001;
33   - }
34   - public static final class drawable {
35   - public static final int ic_action_search=0x7f020000;
36   - public static final int ic_launcher=0x7f020001;
37   - public static final int ic_ledarklogo=0x7f020002;
38   - public static final int ic_menu_name=0x7f020003;
39   - public static final int ic_startbutton=0x7f020004;
40   - public static final int selectedonlist=0x7f020005;
41   - public static final int selectedonlist2=0x7f020006;
42   - public static final int startbuttontoggle=0x7f020007;
43   - }
44   - public static final class id {
45   - public static final int LinearLayout1=0x7f0b0001;
46   - public static final int RelativeLayout1=0x7f0b0006;
47   - public static final int button=0x7f0b0007;
48   - public static final int itemhelp=0x7f0b000d;
49   - public static final int itemprefs=0x7f0b000c;
50   - public static final int listView1=0x7f0b0003;
51   - public static final int menu_settings=0x7f0b000b;
52   - public static final int rowTextView=0x7f0b000a;
53   - public static final int textView1=0x7f0b0004;
54   - public static final int textView2=0x7f0b0005;
55   - public static final int textViewTitle=0x7f0b0002;
56   - public static final int textViewUrl=0x7f0b0009;
57   - public static final int textViewXml=0x7f0b0008;
58   - public static final int videoView1=0x7f0b0000;
59   - }
60   - public static final class layout {
61   - public static final int activity_video=0x7f030000;
62   - public static final int dirs=0x7f030001;
63   - public static final int help=0x7f030002;
64   - public static final int main_activity=0x7f030003;
65   - public static final int rowlayout=0x7f030004;
66   - }
67   - public static final class menu {
68   - public static final int activity_main=0x7f0a0000;
69   - public static final int activity_video=0x7f0a0001;
70   - public static final int menu=0x7f0a0002;
71   - }
72   - public static final class string {
73   - public static final int app_name=0x7f070000;
74   - public static final int button=0x7f07000c;
75   - public static final int button1=0x7f07000d;
76   - public static final int defaultQuality=0x7f070015;
77   - public static final int defaultURL=0x7f070012;
78   - public static final int desc=0x7f070009;
79   - public static final int descarregar=0x7f070003;
80   - public static final int dir=0x7f07000a;
81   - public static final int directoris=0x7f07000b;
82   - public static final int help=0x7f070008;
83   - public static final int helpText=0x7f070011;
84   - public static final int hint=0x7f070004;
85   - public static final int menu_settings=0x7f070001;
86   - public static final int prefs=0x7f070007;
87   - public static final int qual=0x7f070013;
88   - public static final int qual_hint=0x7f070014;
89   - public static final int startbuttondescription=0x7f07000f;
90   - public static final int title=0x7f07000e;
91   - public static final int title_activity_main=0x7f070002;
92   - public static final int title_activity_video=0x7f070010;
93   - public static final int url=0x7f070005;
94   - public static final int urlhint=0x7f070006;
95   - }
96   - public static final class style {
97   - public static final int AppTheme=0x7f090000;
98   - public static final int leBoldText=0x7f090001;
99   - }
100   - public static final class xml {
101   - public static final int prefs=0x7f040000;
102   - }
103   -}
  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 array {
  12 + public static final int qualityNames=0x7f0a0000;
  13 + public static final int qualityValues=0x7f0a0001;
  14 + }
  15 + public static final class attr {
  16 + }
  17 + public static final class color {
  18 + public static final int Black=0x7f080002;
  19 + public static final int Blue=0x7f080004;
  20 + public static final int BlueAndroid=0x7f080005;
  21 + public static final int Gay=0x7f080007;
  22 + public static final int Gray=0x7f08000a;
  23 + public static final int Green=0x7f080009;
  24 + public static final int Orange=0x7f080003;
  25 + public static final int Red=0x7f080008;
  26 + public static final int White=0x7f080006;
  27 + public static final int Whyte_POwaH=0x7f080001;
  28 + public static final int backgroundmain=0x7f080000;
  29 + }
  30 + public static final class dimen {
  31 + public static final int TitleSize=0x7f090000;
  32 + public static final int lesize=0x7f090001;
  33 + }
  34 + public static final class drawable {
  35 + public static final int ic_action_search=0x7f020000;
  36 + public static final int ic_launcher=0x7f020001;
  37 + public static final int ic_ledarklogo=0x7f020002;
  38 + public static final int ic_menu_name=0x7f020003;
  39 + public static final int ic_startbutton=0x7f020004;
  40 + public static final int mediacontroller_bg=0x7f020005;
  41 + public static final int mediacontroller_ff_left=0x7f020006;
  42 + public static final int mediacontroller_ff_right=0x7f020007;
  43 + public static final int mediacontroller_pause01=0x7f020008;
  44 + public static final int mediacontroller_pause02=0x7f020009;
  45 + public static final int mediacontroller_pause_button=0x7f02000a;
  46 + public static final int mediacontroller_play01=0x7f02000b;
  47 + public static final int mediacontroller_play02=0x7f02000c;
  48 + public static final int mediacontroller_play_button=0x7f02000d;
  49 + public static final int mediacontroller_seekbar=0x7f02000e;
  50 + public static final int mediacontroller_seekbar01=0x7f02000f;
  51 + public static final int mediacontroller_seekbar02=0x7f020010;
  52 + public static final int mediacontroller_seekbar_thumb=0x7f020011;
  53 + public static final int selectedonlist=0x7f020012;
  54 + public static final int selectedonlist2=0x7f020013;
  55 + public static final int startbuttontoggle=0x7f020014;
  56 + }
  57 + public static final class id {
  58 + public static final int ImageButton01=0x7f0c000f;
  59 + public static final int ImageButton02=0x7f0c0010;
  60 + public static final int LinearLayout1=0x7f0c0001;
  61 + public static final int RelativeLayout1=0x7f0c0006;
  62 + public static final int VideoView1=0x7f0c0000;
  63 + public static final int button=0x7f0c0007;
  64 + public static final int itemhelp=0x7f0c0014;
  65 + public static final int itemprefs=0x7f0c0013;
  66 + public static final int listView1=0x7f0c0003;
  67 + public static final int mediacontroller_file_name=0x7f0c000d;
  68 + public static final int mediacontroller_play_pause=0x7f0c000e;
  69 + public static final int mediacontroller_seekbar=0x7f0c000c;
  70 + public static final int mediacontroller_time_current=0x7f0c000a;
  71 + public static final int mediacontroller_time_total=0x7f0c000b;
  72 + public static final int menu_settings=0x7f0c0012;
  73 + public static final int rowTextView=0x7f0c0011;
  74 + public static final int textView1=0x7f0c0004;
  75 + public static final int textView2=0x7f0c0005;
  76 + public static final int textViewTitle=0x7f0c0002;
  77 + public static final int textViewUrl=0x7f0c0009;
  78 + public static final int textViewXml=0x7f0c0008;
  79 + }
  80 + public static final class layout {
  81 + public static final int activity_video=0x7f030000;
  82 + public static final int dirs=0x7f030001;
  83 + public static final int help=0x7f030002;
  84 + public static final int main_activity=0x7f030003;
  85 + public static final int mediacontroller=0x7f030004;
  86 + public static final int rowlayout=0x7f030005;
  87 + }
  88 + public static final class menu {
  89 + public static final int activity_main=0x7f0b0000;
  90 + public static final int activity_video=0x7f0b0001;
  91 + public static final int menu=0x7f0b0002;
  92 + }
  93 + public static final class raw {
  94 + public static final int libarm=0x7f050000;
  95 + }
  96 + public static final class string {
  97 + public static final int app_name=0x7f060007;
  98 + public static final int button=0x7f060013;
  99 + public static final int button1=0x7f060014;
  100 + public static final int defaultQuality=0x7f06001c;
  101 + public static final int defaultURL=0x7f060019;
  102 + public static final int desc=0x7f060010;
  103 + public static final int descarregar=0x7f06000a;
  104 + public static final int dir=0x7f060011;
  105 + public static final int directoris=0x7f060012;
  106 + public static final int help=0x7f06000f;
  107 + public static final int helpText=0x7f060018;
  108 + public static final int hint=0x7f06000b;
  109 + public static final int mediacontroller_play_pause=0x7f060006;
  110 + public static final int menu_settings=0x7f060008;
  111 + public static final int prefs=0x7f06000e;
  112 + public static final int qual=0x7f06001a;
  113 + public static final int qual_hint=0x7f06001b;
  114 + public static final int startbuttondescription=0x7f060016;
  115 + public static final int title=0x7f060015;
  116 + public static final int title_activity_main=0x7f060009;
  117 + public static final int title_activity_video=0x7f060017;
  118 + public static final int url=0x7f06000c;
  119 + public static final int urlhint=0x7f06000d;
  120 + public static final int vitamio_init_decoders=0x7f060001;
  121 + public static final int vitamio_name=0x7f060000;
  122 + public static final int vitamio_videoview_error_button=0x7f060005;
  123 + public static final int vitamio_videoview_error_text_invalid_progressive_playback=0x7f060003;
  124 + public static final int vitamio_videoview_error_text_unknown=0x7f060004;
  125 + public static final int vitamio_videoview_error_title=0x7f060002;
  126 + }
  127 + public static final class style {
  128 + public static final int AppTheme=0x7f070002;
  129 + public static final int FullScreen=0x7f070003;
  130 + public static final int MediaController_SeekBar=0x7f070000;
  131 + public static final int MediaController_Text=0x7f070001;
  132 + public static final int leBoldText=0x7f070004;
  133 + }
  134 + public static final class xml {
  135 + public static final int prefs=0x7f040000;
  136 + }
  137 +}
... ...
res/layout/activity_video.xml
1   -<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
2   - xmlns:tools="http://schemas.android.com/tools"
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 3 android:layout_width="match_parent"
4   - android:layout_height="match_parent" >
  4 + android:layout_height="match_parent"
  5 + android:background="@color/Black"
  6 + android:orientation="vertical" >
5 7  
6   - <io.vov.vitamio.widget.VideoView
7   - android:id="@+id/videoView1"
8   - android:layout_width="wrap_content"
9   - android:layout_height="wrap_content"
10   - android:layout_centerHorizontal="true"
11   - android:layout_centerVertical="true" />
  8 + <io.vov.vitamio.widget.CenterLayout
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:background="@color/Black"
  12 + android:orientation="vertical" >
12 13  
13   -</RelativeLayout>
  14 + <io.vov.vitamio.widget.VideoView
  15 + android:id="@+id/VideoView1"
  16 + android:layout_width="match_parent"
  17 + android:layout_height="match_parent"
  18 + android:layout_centerHorizontal="true"
  19 + android:layout_centerVertical="true" />
  20 + </io.vov.vitamio.widget.CenterLayout>
  21 +
  22 +</LinearLayout>
14 23 \ No newline at end of file
... ...
res/values/styles.xml
1 1 <resources>
2 2  
3 3 <style name="AppTheme" parent="android:Theme.Light.NoTitleBar" />
  4 + <style name="FullScreen" parent="android:Theme.NoTitleBar.Fullscreen" />
4 5 <style name="leBoldText">
5 6 <item name="android:textStyle">bold</item>
6 7  
... ...
src/com/upc/pbe/upcnews/HLS.java
... ... @@ -7,9 +7,9 @@ import android.net.TrafficStats;
7 7 import android.util.Log;
8 8  
9 9 //Gestor del protocol HTTP Live Streaming
10   -public class HLS
  10 +public class HLS
11 11 {
12   -
  12 +
13 13 private static final String TAG = "HLS";
14 14 private ArrayList<ParentList> videos;
15 15 private ArrayList<Segment> segments;
... ... @@ -22,11 +22,13 @@ public class HLS
22 22 private Descarrega d;
23 23 private BandwidthMeasurer bm;
24 24  
25   - public HLS(ArrayList<ParentList> parsed, String localFolder) {
26   - //Neteja el directori i inicialitza les variables
  25 + public HLS(ArrayList<ParentList> parsed, String localFolder)
  26 + {
  27 + // Neteja el directori i inicialitza les variables
27 28 File dir = new File(localFolder);
28 29 String[] files = dir.list();
29   - for (int i = 0; i < files.length; i++) {
  30 + for (int i = 0; i < files.length; i++)
  31 + {
30 32 File deleteme = new File(dir, files[i]);
31 33 Log.d(TAG, "Esborrat " + files[i].toString());
32 34 deleteme.delete();
... ... @@ -40,19 +42,24 @@ public class HLS
40 42 d = new Descarrega();
41 43 }
42 44  
43   - public void loadVideo() {
44   - //Carrega la seguent qualitat i, a partir d'aixo, el seguent segment
  45 + public void loadVideo()
  46 + {
  47 + // Carrega la qualitat i, a partir d'aixo, el seguent segment
45 48 qualities = videos.get(currentVideo++).getLists();
46 49 segments = qualities.get(currentQuality).getSegments();
47   - if (currentVideo == videos.size()) {
  50 + if (currentVideo == videos.size())
  51 + {
48 52 endReached = true;
49 53 }
50 54 }
51 55  
52   - public String next() throws IOException {
53   - //Determina la seguent qualitat a partir de la velocitat
54   - if(currentSegment == segments.size()) {
55   - if(endReached) {
  56 + public String next() throws IOException
  57 + {
  58 + // Determina la seguent qualitat a partir de la velocitat
  59 + if (currentSegment == segments.size())
  60 + {
  61 + if (endReached)
  62 + {
56 63 return null;
57 64 }
58 65 loadVideo();
... ... @@ -61,15 +68,28 @@ public class HLS
61 68 Log.d(TAG, seg.getName() + " " + seg.getURL());
62 69 long startTime = System.currentTimeMillis();
63 70 long segmentBytes = TrafficStats.getTotalRxBytes();
64   - d.descarregarguardar(seg.getURL(),localFolder);
65   - double bps = bm.Measure(segmentBytes,startTime);
66   - Log.d(TAG, "Velocitat actual (KB/s): " + (bps/8e3));
67   - if((bps < qualities.get(currentQuality).getQuality()) && (bps != -1)) {
  71 + d.descarregarguardar(seg.getURL(), localFolder);
  72 + double bps = bm.Measure(segmentBytes, startTime);
  73 + Log.d(TAG, "Velocitat actual (KB/s): " + (bps / 8e3));
  74 + if ((bps < qualities.get(currentQuality).getQuality()) && (bps != -1))
  75 + {
68 76 currentQuality++;
69 77 }
70   - return localFolder + seg.getURL().substring(seg.getURL().lastIndexOf("/")+1, seg.getURL().length());
  78 + return localFolder
  79 + + seg.getURL().substring(seg.getURL().lastIndexOf("/") + 1, seg.getURL().length());
71 80 }
72   -
  81 +
  82 + public String previous() throws IOException
  83 + {
  84 + Segment seg = null;
  85 + if (--currentSegment > 0)
  86 + {
  87 + --currentSegment;
  88 + }
  89 + seg = segments.get(currentSegment++);
  90 + return localFolder + seg.getURL().substring(seg.getURL().lastIndexOf("/") + 1, seg.getURL().length());
  91 + }
  92 +
73 93 public void setDefQuality(int q)
74 94 {
75 95 currentQuality = q;
... ...
src/com/upc/pbe/upcnews/MainActivity.java
... ... @@ -101,12 +101,12 @@ public class MainActivity extends Activity implements OnClickListener {
101 101 }
102 102 /*
103 103 * COSAS POR HACER
104   - * Añadir gif Imanol bailando
105   - * Que cojones pasa con los codecs -- Imanol
106   - * Descarga en segundo plano (Mejora dificil)
107   - * Lentitud descarga -- Todos (este miercoles)
108   - * Poner la defaultURL al server de PBE
109   - * Que cada uno documente minimamente su codigo
  104 + * (RELEASE-CRITICAL) Lentitud descarga -- Todos (este miercoles)
  105 + * (RELEASE-CRITICAL) Hacer que funcione el proyecto en un dispositivo diferente a la tablet (Caray! debería!!)
  106 + * (SEVERE) Crash preferences (Me sigue saliendo O.o)
  107 + * (NORMAL) Poner la defaultURL al server de PBE
  108 + * (WISHLIST) Descarga en segundo plano (Mejora dificil)
  109 + * (WISHLIST) A�adir gif Imanol bailando (Easter eggs? váis en serio? XDDDDDDDDDDDD)
110 110 * Borrar esta puta mierda
111 111 */
112 112 }
113 113 \ No newline at end of file
... ...
src/com/upc/pbe/upcnews/VideoActivity.java
1 1 package com.upc.pbe.upcnews;
2 2  
  3 +import io.vov.vitamio.MediaPlayer;
  4 +import io.vov.vitamio.widget.MediaController;
  5 +import io.vov.vitamio.widget.VideoView;
  6 +
3 7 import java.io.IOException;
4 8  
5   -import io.vov.vitamio.widget.VideoView;
6 9 import android.app.Activity;
7   -import io.vov.vitamio.MediaPlayer;
  10 +import android.content.res.Configuration;
8 11 import android.os.Bundle;
9 12 import android.util.Log;
10   -import android.view.Menu;
11   -import io.vov.vitamio.widget.MediaController;
  13 +import android.view.View;
12 14 import android.widget.Toast;
13 15  
14 16 //Tercera activitat principal, executa la reproduccio del video sencer
... ... @@ -16,7 +18,8 @@ public class VideoActivity extends Activity {
16 18  
17 19 private final static String TAG = "VideoActivity";
18 20 private VideoView video;
19   - private HLS h;
  21 + private HLS h = null;
  22 +
20 23  
21 24 @Override
22 25 public void onCreate(Bundle savedInstanceState) {
... ... @@ -28,18 +31,36 @@ public class VideoActivity extends Activity {
28 31 return;
29 32 }
30 33 setContentView(R.layout.activity_video);
31   - video = (VideoView) findViewById(R.id.videoView1);
  34 + video = (VideoView) findViewById(R.id.VideoView1);
32 35 //Creem un listener associat al fi de l'activitat (el fi de cada ts)
  36 + io.vov.vitamio.widget.MediaController mc = new MediaController(this);
33 37 video.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
34 38 public void onCompletion(MediaPlayer mp) {
35 39 //Al acabar cada ts, reproduit el seguent
36 40 playNext();
37 41 }
38 42 });
  43 + mc.setOnFFLeftListener(new View.OnClickListener() {
  44 + public void onClick(View v) {
  45 + Log.d(TAG, "FFLEFT");
  46 + video.stopPlayback();
  47 + playPrevious();
  48 + }
  49 + });
  50 + mc.setOnFFRightListener(new View.OnClickListener() {
  51 + public void onClick(View v) {
  52 + Log.d(TAG, "FFRIGHT");
  53 + video.stopPlayback();
  54 + playNext();
  55 + }
  56 + });
  57 + video.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
39 58 //Creem un gestor HLS, carreguem el video i iniciem la reproduccio
40 59 h = ((UpcApp)getApplication()).getHLS();
41 60 h.setDefQuality(((UpcApp)getApplication()).getQuality());
42 61 h.loadVideo();
  62 + video.stopPlayback();
  63 + video.setMediaController(mc);
43 64 playNext();
44 65 }
45 66  
... ... @@ -48,12 +69,10 @@ public class VideoActivity extends Activity {
48 69 super.finish();
49 70 return;
50 71 }
51   - Log.d(TAG,url);
52   - video.setVideoPath(url);
53   - video.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH);
54   - video.setMediaController(new MediaController(this));
55   - /*video.start();
56   - video.requestFocus();*/
  72 + Log.d(TAG,"A reproduir: " + url);
  73 + video.setVideoPath("file://" + url);
  74 + video.start();
  75 + video.requestFocus();
57 76 }
58 77  
59 78 public void playNext() {
... ... @@ -67,11 +86,30 @@ public class VideoActivity extends Activity {
67 86 return;
68 87 }
69 88 }
70   -
  89 + public void playPrevious() {
  90 + try {
  91 + String prev = h.previous();
  92 + play(prev);
  93 + }
  94 + catch(IOException e) {
  95 + Toast.makeText(this, "No s'ha trobat el segment", Toast.LENGTH_LONG).show();
  96 + super.finish();
  97 + return;
  98 + }
  99 + }
  100 +
71 101 @Override
  102 + public void onConfigurationChanged(Configuration newConfig) {
  103 + if (video != null)
  104 + video.setVideoLayout(VideoView.VIDEO_LAYOUT_SCALE, 0);
  105 + super.onConfigurationChanged(newConfig);
  106 + }
  107 +
  108 + // Que coño es esto gueyes???
  109 + /*@Override
72 110 public boolean onCreateOptionsMenu(Menu menu) {
73 111 //Determina el funcionament al apretar la tecla d'opcions
74 112 getMenuInflater().inflate(R.menu.activity_video, menu);
75 113 return true;
76   - }
  114 + }*/
77 115 }
78 116 \ No newline at end of file
... ...