diff --git a/src/com/upc/pbe/upcnews/Directoris.java b/src/com/upc/pbe/upcnews/Directoris.java index 19eb8ea..4ece619 100644 --- a/src/com/upc/pbe/upcnews/Directoris.java +++ b/src/com/upc/pbe/upcnews/Directoris.java @@ -4,7 +4,9 @@ import java.io.IOException; import java.util.ArrayList; import android.app.Activity; +import android.content.ComponentName; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.util.Log; import android.view.KeyEvent; @@ -76,7 +78,21 @@ public class Directoris extends Activity implements OnItemClickListener { ArrayList m3u8parsed = p.parseFile(playlist); Log.d(TAG, "parsing completed"); HLS h = new HLS(m3u8parsed,((UpcApp)getApplication()).getLocalPath()); - h.start(); + h.loadVideo(); + /* + * while(true) + * { + * String[] segment = h.next(); + * if(segment == null) + * { + * break; + * } + * Log.d(TAG,segment[0]); + * startPlayer(segment[0],segment[1]); + */ + String[] test = {"/sdcard/a.ts","LE TEST"}; + startPlayer(test[0],test[1]); + } catch (ErrorException e){ Toast.makeText(this, e.getMessage(), Toast.LENGTH_SHORT).show(); @@ -108,29 +124,15 @@ public class Directoris extends Activity implements OnItemClickListener { } } - public boolean onCreateOptionsMenu(Menu menu){ - //Determina el funcionament al apretar la tecla d'opcions - getMenuInflater().inflate(R.menu.menu, menu); - Log.d(TAG, "Menu"); - return true; + private void startPlayer(String url, String title) { + Intent i = new Intent(); + i.setComponent(new ComponentName("me.abitno.vplayer.t", "me.abitno.vplayer.VideoActivity")); + i.setAction("me.abitno.vplayer.action.VIEW"); + i.setData(Uri.parse(url)); + i.putExtra("displayName", title); + startActivity(i); } - - public boolean onOptionsItemSelected(MenuItem item){ - //Determina el funcionament al clickar en el menu d'opcions - switch (item.getItemId()){ - case R.id.itemprefs: - startActivity(new Intent(this, Prefs.class)); - Log.d(TAG, "Preferences"); - return true; - case R.id.itemhelp: - startActivity(new Intent(this, Help.class)); - Log.d(TAG, "Help"); - return true; - default: - return false; - } - } - + public boolean onKeyDown(int keyCode, KeyEvent event) { //Determina el funcionament al apretar la tecla de tornar enrere if (keyCode == KeyEvent.KEYCODE_BACK && event.getRepeatCount() == 0){ diff --git a/src/com/upc/pbe/upcnews/HLS.java b/src/com/upc/pbe/upcnews/HLS.java index a7fb2ae..a5353ad 100644 --- a/src/com/upc/pbe/upcnews/HLS.java +++ b/src/com/upc/pbe/upcnews/HLS.java @@ -2,6 +2,9 @@ package com.upc.pbe.upcnews; import java.util.ArrayList; +import android.content.ComponentName; +import android.content.Intent; +import android.net.Uri; import android.util.Log; //Gestor del protocol HTTP Live Streaming @@ -9,6 +12,8 @@ public class HLS { private static final String TAG = "HLS"; private ArrayList videos; + private ArrayList segments; + private ArrayList