Skip to content

Commit

Permalink
Added VOD functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
tordo committed Dec 11, 2012
1 parent 4c23ca9 commit 2678461
Show file tree
Hide file tree
Showing 12 changed files with 864 additions and 19 deletions.
11 changes: 10 additions & 1 deletion GSLDroid/res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/go" />
android:text="@string/login" />

<TextView
android:id="@+id/tw_status"
Expand All @@ -58,4 +58,13 @@
android:text="@string/empty_string"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:linksClickable="true"
android:text="@string/helptext"
android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>
83 changes: 83 additions & 0 deletions GSLDroid/res/layout/play_vod_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="vertical" >

<TextView
android:id="@+id/tv_matchname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Large Text"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView
android:id="@+id/tv_matchtournament"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/tv_matchplayers"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Medium Text"
android:textAppearance="?android:attr/textAppearanceMedium" />

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="right" >

<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:text="@string/set"
android:textAppearance="?android:attr/textAppearanceMedium" />

<Spinner
android:id="@+id/spin_matchset"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />

</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical|right" >

<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/quality"
android:textAppearance="?android:attr/textAppearanceMedium" />

<Spinner
android:id="@+id/spin_matchquality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1" />

</LinearLayout>

<Button
android:id="@+id/but_matchgo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/go" />

<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/donttrytoskip"
android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>
49 changes: 49 additions & 0 deletions GSLDroid/res/layout/vod_item.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ImageView
android:id="@+id/imageView1"
android:layout_width="130px"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/tv_players"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/ic_launcher" />

<TextView
android:id="@+id/tv_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_tournament"
android:layout_toRightOf="@+id/imageView1"
android:text="TextView" />

<TextView
android:id="@+id/tv_tournament"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_toRightOf="@+id/imageView1"
android:text="TextView" />

<TextView
android:id="@+id/tv_players"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/tv_name"
android:layout_toRightOf="@+id/imageView1"
android:text="TextView" />

<TextView
android:id="@+id/tv_date"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="TextView" />

</RelativeLayout>
39 changes: 39 additions & 0 deletions GSLDroid/res/layout/vod_list.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >

<ListView
android:id="@+id/lv_vodlist"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_weight="0.8"
android:scrollbars="none" >
</ListView>

<RelativeLayout
android:id="@+id/RelativeLayout1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="0.2"
android:orientation="horizontal" >

<Button
android:id="@+id/bt_prev"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/prev_page" />

<Button
android:id="@+id/bt_next"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:text="@string/next_page" />
</RelativeLayout>

</LinearLayout>
9 changes: 8 additions & 1 deletion GSLDroid/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,18 @@
<string name="app_name">GSLDroid</string>
<string name="settings">Settings</string>
<string name="key_username">GSLDROID_USERNAME</string>
<string name="hr_username">Username</string>
<string name="hr_username">E-mail address</string>
<string name="hr_password">Password</string>
<string name="key_password">GSLDROID_PASSWORD</string>
<string name="play">Play</string>
<string name="go">GO</string>
<string name="empty_string"></string>
<string name="login">Log in</string>
<string name="next_page">&gt;&gt;</string>
<string name="prev_page">&lt;&lt;</string>
<string name="set">Set</string>
<string name="quality">"Quality "</string>
<string name="helptext">Please note that you need VLC for Android to play the VODs. MX Player will NOT work.</string>
<string name="donttrytoskip">Do NOT try to seek in VLC, it will cause weird things to happen. If you seek by accident, just restart the VOD.</string>

</resources>
39 changes: 26 additions & 13 deletions GSLDroid/src/net/fortito/gsldroid/GOMStreamGrabber.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.apache.http.message.BasicNameValuePair;
import org.apache.http.protocol.BasicHttpContext;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.media.MediaPlayer;
Expand Down Expand Up @@ -47,7 +48,7 @@ public class GOMStreamGrabber {
/** GOMTV Password */
private String m_password;
/** Video quality */
private String m_quality;
protected String m_quality;

/** Stream Quality: SQ TEST */
public static final String QUALITY_SQ_TEST = "SQTest";
Expand All @@ -56,6 +57,7 @@ public class GOMStreamGrabber {
/** Stream Quality: HQ */
public static final String QUALITY_HQ = "HQ";

private boolean m_loggedin = false;

/** Http client to do our requests */
private AndroidHttpClient m_httpclient;
Expand All @@ -65,7 +67,7 @@ public class GOMStreamGrabber {
private BasicCookieStore m_cookies;

/** Context */
private GSLDroidActivity m_activity;
protected Activity m_activity;

/** Tag for logging */
private static final String TAG = "GOMStreamGrabber";
Expand All @@ -79,7 +81,7 @@ public class GOMStreamGrabber {
* @param username GOMTV username
* @param password GOMTV password
*/
public GOMStreamGrabber(GSLDroidActivity act, String username, String password, String quality)
public GOMStreamGrabber(Activity act, String username, String password, String quality)
{
m_activity = act;
m_username = username;
Expand All @@ -93,6 +95,7 @@ public GOMStreamGrabber(GSLDroidActivity act, String username, String password,
m_httpcontext.setAttribute(ClientContext.COOKIE_STORE, m_cookies);
}


/**
* Start the stream. This does:
* - Login
Expand All @@ -105,11 +108,11 @@ public GOMStreamGrabber(GSLDroidActivity act, String username, String password,
public void
startStream() throws GOMStreamException
{
m_activity.showUserMsg("Logging in");
showUserMsg("Logging in");
login();

String livepage = "";
m_activity.showUserMsg("Getting live page");
showUserMsg("Getting live page");
try {
livepage = getPage(getLivePageURL(null));
} catch (IllegalStateException e) {
Expand All @@ -121,7 +124,7 @@ public GOMStreamGrabber(GSLDroidActivity act, String username, String password,
}
String goxxml = getGOXXML(livepage);
String url = "";
m_activity.showUserMsg("Getting GOX XML");
showUserMsg("Getting GOX XML");
try {
url = getStreamURL(getPage(goxxml));
} catch (IllegalStateException e) {
Expand All @@ -131,21 +134,24 @@ public GOMStreamGrabber(GSLDroidActivity act, String username, String password,
e.printStackTrace();
throw new GOMStreamException(GOMStreamException.ERROR_GET_GOX_XML, "Could not get GOX XML");
}
m_activity.showUserMsg("Starting stream");
showUserMsg("Starting stream");
if(url.equals(""))
{
throw new GOMStreamException(GOMStreamException.ERROR_EMPTY_STREAM_URL, "Got empty stream URL - are you sure you have bought a season pass?");
}
playStream(url);
m_activity.showUserMsg("");
showUserMsg("");
}
public void setQuality(String quality)
{
m_quality = quality;
}

/**
* Login to GOMtv.net
* This function logs in to GOMtv.net, and the login cookies are set in m_httpcontext/m_cookies as a result.
* @throws GOMStreamException
*/
private void
protected void
login() throws GOMStreamException
{
// Build HTTP Request
Expand Down Expand Up @@ -179,18 +185,20 @@ public GOMStreamGrabber(GSLDroidActivity act, String username, String password,
// If we didn't get any cookies, fail
if(m_cookies.getCookies().size() == 0)
throw new GOMStreamException(GOMStreamException.ERROR_LOGIN, "Did not get cookies, wrong username/password?");

m_loggedin = true;
Log.d(TAG, "Logged in!");
}

/**
* Get the contents of a page, using the local httpcontext
* @param URL The url of the page to get
* @return The contents of the page
* @throws GOMStreamException
*/
private String
getPage(String URL) throws IOException,IllegalStateException
protected String
getPage(String URL) throws IOException,IllegalStateException, GOMStreamException
{
if(!m_loggedin) login();
HttpGet req = new HttpGet(URL);
HttpResponse response = m_httpclient.execute(req,m_httpcontext);

Expand Down Expand Up @@ -306,4 +314,9 @@ public GOMStreamException(int id, String msg){
this.id = id;
}
}

public void showUserMsg(String s)
{

}
}
Loading

0 comments on commit 2678461

Please sign in to comment.