diff options
author | lado <herrlado@gmail.com> | 2011-09-07 09:50:16 +0200 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2011-09-07 09:50:16 +0200 |
commit | adf15c58d390eace444149e9ab90acbcf456ae9c (patch) | |
tree | 1b09d8bd84d2ae61eda3b740302a9733c20cf20b | |
parent | 1f38710cbed1e6fd6507376e3cb5c5b3c509de39 (diff) | |
download | vdr-manager-adf15c58d390eace444149e9ab90acbcf456ae9c.tar.gz vdr-manager-adf15c58d390eace444149e9ab90acbcf456ae9c.tar.bz2 |
added streaming support for external players. Fixed a npe in ChannelListActivity
-rw-r--r-- | vdrmanager/AndroidManifest.xml | 3 | ||||
-rw-r--r-- | vdrmanager/res/values/arrays.xml | 15 | ||||
-rw-r--r-- | vdrmanager/res/values/preferences_keys.xml | 2 | ||||
-rw-r--r-- | vdrmanager/res/values/strings.xml | 7 | ||||
-rw-r--r-- | vdrmanager/res/xml/preferences.xml | 18 | ||||
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java | 18 | ||||
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java | 81 | ||||
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/gui/VideoActivity.java | 67 |
8 files changed, 103 insertions, 108 deletions
diff --git a/vdrmanager/AndroidManifest.xml b/vdrmanager/AndroidManifest.xml index 19cc0ec..d17268a 100644 --- a/vdrmanager/AndroidManifest.xml +++ b/vdrmanager/AndroidManifest.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="de.bjusystems.vdrmanager" - android:versionName="0.1" android:versionCode="0"> + android:versionName="0.2" android:versionCode="02"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true" android:name=".app.VdrManagerApp"> @@ -20,7 +20,6 @@ <activity android:name=".gui.TimerDetailsActivity"></activity> <activity android:name=".gui.EpgSearchActivity"></activity> <activity android:name=".gui.EpgSearchTimesListActivity"></activity> -<activity android:name=".gui.VideoActivity"></activity> </application> diff --git a/vdrmanager/res/values/arrays.xml b/vdrmanager/res/values/arrays.xml new file mode 100644 index 0000000..7b5b28a --- /dev/null +++ b/vdrmanager/res/values/arrays.xml @@ -0,0 +1,15 @@ +<?xml version="1.0" encoding="utf-8"?> +<resources> + <string-array name="livetv_streamformat"> + <item>TS</item> + <item>PES</item> + <item>ES</item> + <item>PS</item> + </string-array> + <string-array name="livetv_streamformat_values"> + <item>TS</item> + <item>PES</item> + <item>ES</item> + <item>PS</item> + </string-array> +</resources>
\ No newline at end of file diff --git a/vdrmanager/res/values/preferences_keys.xml b/vdrmanager/res/values/preferences_keys.xml index 36fee64..7eb0c6d 100644 --- a/vdrmanager/res/values/preferences_keys.xml +++ b/vdrmanager/res/values/preferences_keys.xml @@ -5,6 +5,8 @@ <string name="vdr_port_key">svdrp_port </string> <string name="vdr_password_key">svdrp_password</string> <string name="vdr_ssl_key">svdrp_ssl</string> + <string name="vdr_stream_format">stream_format</string> + <string name="vdr_stream_port">stream_port</string> <string name="alive_check_enabled_key">alive_check_enabled</string> <string name="alive_check_interval_key">alive_check_interval</string> diff --git a/vdrmanager/res/values/strings.xml b/vdrmanager/res/values/strings.xml index 1fcd07e..47eb950 100644 --- a/vdrmanager/res/values/strings.xml +++ b/vdrmanager/res/values/strings.xml @@ -1,5 +1,8 @@ <?xml version="1.0" encoding="utf-8"?> <resources> - - + <string name="livetv">Live TV</string> + <string name="settings_livetv_summary">Needs streamdev-server on VDR and an external player such as VPlayer</string> + <string name="settings_livetv_streamformat">Streamformat</string> + <string name="settings_livetv_port">Streaming Port</string> + <string name="settings_livetv_port_summary">Default 3000. The access must be enabled in streamdevhosts.conf.</string> </resources> diff --git a/vdrmanager/res/xml/preferences.xml b/vdrmanager/res/xml/preferences.xml index 8a84449..15044f6 100644 --- a/vdrmanager/res/xml/preferences.xml +++ b/vdrmanager/res/xml/preferences.xml @@ -25,6 +25,14 @@ android:key="@string/vdr_ssl_key" android:title="@string/vdr_ssl_title" android:summary="@string/vdr_ssl_summary"/> + + + <EditTextPreference + android:key="streamingport" + android:inputType="number" + android:title="@string/settings_livetv_port" + android:summary="@string/settings_livetv_port_summary" + android:defaultValue="3000" /> </PreferenceCategory> @@ -96,5 +104,15 @@ android:defaultValue="50"/> </PreferenceCategory> + + + <PreferenceCategory android:title="@string/livetv"> + <ListPreference + android:key="livetv_streamformat" + android:title="@string/settings_livetv_streamformat" + android:defaultValue="TS" + android:entries="@array/livetv_streamformat" + android:entryValues="@array/livetv_streamformat_values" /> + </PreferenceCategory> </PreferenceScreen> diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java index 3e1fc8a..9bb7c13 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/data/Preferences.java @@ -43,6 +43,18 @@ public class Preferences { private int timerDefaultLifetime; /** user defined epg search times */ private String epgSearchTimes; + + private int streamPort = 3000; + + public int getStreamPort() { + return streamPort; + } + + public String getStreamFormat() { + return streamFormat; + } + + private String streamFormat = "TS"; /** Properties singleton */ private static Preferences thePrefs; @@ -226,11 +238,13 @@ public class Preferences { final Preferences prefs = new Preferences(); - prefs.svdrpHost = getString(context, sharedPrefs, R.string.vdr_host_key, "10.0.2.2"); + prefs.svdrpHost = getString(context, sharedPrefs, R.string.vdr_host_key, "127.0.0.1"); prefs.svdrpPort = getInt(context, sharedPrefs, R.string.vdr_port_key, 6419); prefs.password = getString(context, sharedPrefs, R.string.vdr_password_key, ""); prefs.ssl = getBoolean(context, sharedPrefs, R.string.vdr_ssl_key, false); - + prefs.streamPort = getInt(context, sharedPrefs, R.string.vdr_stream_port, 3000); + prefs.streamFormat= getString(context, sharedPrefs, R.string.vdr_stream_format, "TS"); + prefs.aliveCheckEnabled = getBoolean(context, sharedPrefs, R.string.alive_check_enabled_key, false); prefs.aliveCheckInterval = getInt(context, sharedPrefs, R.string.alive_check_interval_key, 60); diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java index ac12efd..3d61b56 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/ChannelListActivity.java @@ -5,6 +5,7 @@ import java.util.List; import android.app.Activity; import android.content.Intent; +import android.net.Uri; import android.os.Bundle; import android.view.ContextMenu; import android.view.ContextMenu.ContextMenuInfo; @@ -26,12 +27,12 @@ import de.bjusystems.vdrmanager.utils.svdrp.SvdrpEvent; import de.bjusystems.vdrmanager.utils.svdrp.SvdrpException; /** - * This class is used for showing what's - * current running on all channels + * This class is used for showing what's current running on all channels + * * @author bju */ -public class ChannelListActivity extends Activity - implements OnItemClickListener, SvdrpAsyncListener<Channel> { +public class ChannelListActivity extends Activity implements + OnItemClickListener, SvdrpAsyncListener<Channel> { ChannelClient channelClient; ChannelAdapter adapter; @@ -53,17 +54,17 @@ public class ChannelListActivity extends Activity // register context menu registerForContextMenu(listView); - // create channel list channels = new ArrayList<Channel>(); listView.setOnItemClickListener(this); } - public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { + public void onItemClick(final AdapterView<?> parent, final View view, + final int position, final long id) { // find and remember item - final Channel channel = (Channel) parent.getAdapter().getItem(position); + final Channel channel = adapter.getItem(position); final VdrManagerApp app = (VdrManagerApp) getApplication(); app.setCurrentChannel(channel); app.setChannels(channels); @@ -74,8 +75,6 @@ public class ChannelListActivity extends Activity startActivity(intent); } - - @Override protected void onResume() { super.onResume(); @@ -100,7 +99,8 @@ public class ChannelListActivity extends Activity channelClient = new ChannelClient(); // create background task - final SvdrpAsyncTask<Channel, SvdrpClient<Channel>> task = new SvdrpAsyncTask<Channel, SvdrpClient<Channel>>(channelClient); + final SvdrpAsyncTask<Channel, SvdrpClient<Channel>> task = new SvdrpAsyncTask<Channel, SvdrpClient<Channel>>( + channelClient); // create progress progress = new SvdrpProgressDialog(this, channelClient); @@ -128,7 +128,7 @@ public class ChannelListActivity extends Activity break; case FINISHED: channels.addAll(channelClient.getResults()); - for(final Channel channel : channels) { + for (final Channel channel : channels) { adapter.add(channel); } progress = null; @@ -142,46 +142,57 @@ public class ChannelListActivity extends Activity } @Override - public void onCreateContextMenu(final ContextMenu menu, final View v, final ContextMenuInfo menuInfo) { + public void onCreateContextMenu(final ContextMenu menu, final View v, + final ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); if (v.getId() == R.id.channel_list) { - final MenuInflater inflater = getMenuInflater(); - final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)menuInfo; + final MenuInflater inflater = getMenuInflater(); + final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) menuInfo; - // set menu title - final Channel item = adapter.getItem(info.position); - menu.setHeaderTitle(item.getName()); + // set menu title + final Channel item = adapter.getItem(info.position); + menu.setHeaderTitle(item.getName()); - inflater.inflate(R.menu.channel_list_item_menu, menu); + inflater.inflate(R.menu.channel_list_item_menu, menu); } } - - @Override public boolean onContextItemSelected(final MenuItem item) { - final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo)item.getMenuInfo(); - final Channel channel = adapter.getItem(info.position); - - switch (item.getItemId()) { - case R.id.channel_item_menu_epg: - onItemClick(null, null, info.position, 0); - break; - case R.id.channel_item_menu_stream: - // show live stream - showStream(channel); - break; + final AdapterView.AdapterContextMenuInfo info = (AdapterView.AdapterContextMenuInfo) item + .getMenuInfo(); + final Channel channel = adapter.getItem(info.position); + + switch (item.getItemId()) { + case R.id.channel_item_menu_epg: + onItemClick(null, null, info.position, 0); + break; + case R.id.channel_item_menu_stream: + // show live stream + showStream(channel); + break; } return true; } + private String getStreamUrl(Channel c) { + //"http://192.168.1.119:3000/TS/" + StringBuilder sb = new StringBuilder(); + Preferences p = Preferences.getPreferences(); + sb.append("http://").append(p.getSvdrpHost()).append(":") + .append(p.getStreamPort()).append("/") + .append(p.getStreamFormat()).append("/") + .append(c.getNumber()); + return sb.toString(); + } private void showStream(final Channel channel) { - // show stream - final Intent intent = new Intent(); - intent.setClass(this, VideoActivity.class); - startActivity(intent); + + String url = getStreamUrl(channel); + final Intent intent = new Intent(Intent.ACTION_VIEW); + intent.setDataAndType(Uri.parse(url.toString()),"video/*"); + startActivityForResult(intent, 1); } } diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VideoActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VideoActivity.java deleted file mode 100644 index 6e17d15..0000000 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VideoActivity.java +++ /dev/null @@ -1,67 +0,0 @@ -package de.bjusystems.vdrmanager.gui; - -import android.app.Activity; -import android.net.Uri; -import android.os.Bundle; -import android.view.View; -import android.view.View.OnClickListener; -import android.widget.Button; -import android.widget.MediaController; -import android.widget.VideoView; -import de.bjusystems.vdrmanager.R; -import de.bjusystems.vdrmanager.data.Preferences; - -/** - * This class is used for showing what's - * current running on all channels - * @author bju - */ -public class VideoActivity extends Activity - implements OnClickListener { - - Preferences prefs; - - @Override - protected void onCreate(final Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - - // Attach view - setContentView(R.layout.video); - - // set stream - final VideoView videoView = (VideoView) findViewById(R.id.video_video); - final MediaController mediaController = new MediaController(this); - mediaController.setAnchorView(videoView); - final Uri video = Uri.parse("http://192.168.178.20:3000/1"); - videoView.setMediaController(mediaController); - videoView.setVideoURI(video); - videoView.start(); - - // register button - final Button button = (Button) findViewById(R.id.video_button); - button.setOnClickListener(this); - } - - @Override - protected void onResume() { - super.onResume(); - } - - @Override - protected void onPause() { - super.onPause(); - } - - public void onClick(final View v) { - - // Save search parameters -// final EpgSearchParams search = new EpgSearchParams(); -// search.setTitle(text.getText().toString()); -// ((VdrManagerApp)getApplication()).setCurrentSearch(search); - - // show timer details -// final Intent intent = new Intent(); -// intent.setClass(this, VdrManagerActivity.class); -// startActivity(intent); - } -} |