...
Code Block | ||||
---|---|---|---|---|
| ||||
public class VideoPlayer extends SpringStreamsActivity { VideoView videoView; /** * */ public VideoPlayer() { super("test", "Streaming Test App"); } public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); videoView = ...; } @Override protected void onStart() { Map<String, Object> atts = new HashMap<String, Object>(); atts.put("stream", "android/teststream"); super.track(new VideoViewAdapter(this.videoView), atts); super.onStart(); } } |
ProGuard
Please Note: If you are using ProGuard, our library could be compromised.
Therefore it is necessary to add the following lines into the ProGuard configuration file:
# Keep spring files
-keep class de.spring.** { *; }
If using version spring-appstreaming-android-1.2.5 (and lower), it is necessary to add the following lines into the ProGuard configuration file:
# Keep spring files
-keep class de.spring.** { *; }
-keep class org.apache.** { *; }
If you want to suppress the warnings regarding library-program-class-dependencies , please add to the configuration file
-dontwarn android.webkit.WebView
-dontwarn android.webkit.WebViewClient
Appendix A
Anchor Anhang A Anhang A
In the following example, the adapter has been implemented for the VideoView
from the standard API.
Code Block | ||
---|---|---|
| ||
/** * Implementation of an adapter for the {@link VideoView} in standard * android api. * * @author <a href="mailto:support@spring.de">spring GmbH & Co.KG</a> */ public class VideoViewAdapter implements StreamAdapter { private VideoView videoView; public VideoViewAdapter(VideoView videoView) { if(videoView == null) throw new NullPointerException("videoView may not be null"); this.videoView = videoView; } @Override public Meta getMeta() { return new Meta() { public String getPlayerName() { return "android.widget.VideoView"; } public String getPlayerVersion() { return Build.VERSION.RELEASE; } public int getScreenHeight() { return (((WindowManager)videoView.getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay()).getHeight(); } public int getScreenWidth() { return (((WindowManager)videoView.getContext().getSystemService(Context.WINDOW_SERVICE)) .getDefaultDisplay()).getWidth(); } }; } @Override public int getPosition() { return (int)Math.round(videoView.getCurrentPosition()/1000.0); } @Override public int getDuration() { return (int)Math.round(videoView.getDuration()/1000.0); } @Override public int getWidth() { return videoView.getWidth(); } @Override public int getHeight() { return videoView.getHeight(); } } |
Appendix B
Anchor Anhang B Anhang B
The source code of class SpringStreamsActivity
Code Block | ||||
---|---|---|---|---|
| ||||
package de.spring.mobile; import java.util.Map; import android.app.Activity; import android.os.Bundle; /** * * @author <a href="mailto:support@spring.de">spring GmbH & Co.KG</a> */ public abstract class SpringStreamsActivity extends Activity { private static SpringStreams sensor; private static int instances = 0; private Stream stream; public SpringStreamsActivity(String site, String appName) { this(site, appName, 10); } public SpringStreamsActivity(String site, String appName, int timeout) { if(site == null) throw new NullPointerException("parameter site may not be null"); if(appName == null) throw new NullPointerException("parameter appName may not be null"); if(sensor == null) { sensor = new SpringStreams(site, appName, getApplicationContext()); sensor.setTimeout(timeout); } } public Stream getStream() { return stream; } public void setSensorDebug(boolean debug) { sensor.setDebug(debug); } public boolean isSensorDebug() { return sensor.isDebug(); } public void setTracking(boolean tracking) { sensor.setTracking(tracking); } public boolean isTracking() { return sensor.isTracking(); } public void track(StreamAdapter adapter, Map<String, Object> atts) { if(this.stream != null) { stream.stop(); stream = null; } stream = sensor.track(adapter, atts); } /** * @see android.app.Activity#onCreate(android.os.Bundle) */ @Override protected void onCreate(Bundle savedInstanceState) { instances++; super.onCreate(savedInstanceState); } /** * @see android.app.Activity#onStop() */ @Override protected void onStop() { if(stream != null) { stream.stop(); stream = null; } super.onStop(); } /** * @see android.app.Activity#onDestroy() */ @Override protected void onDestroy() { instances--; if(instances <= 0) { sensor.unload(); sensor = null; stream = null; } super.onDestroy(); } } |
...