Streaming Measurement in Android
This chapter describes the basic use of the sensor for the measurement of streaming content.
Properties of the Library
Property | Default | Description |
---|---|---|
tracking | true | If this property is set to |
offlineMode | false | If this property is set to |
debug | false | If the value is set to true , the debug messages are issued by the library. |
timeout | 10 | Timeout Setting for the HTTP-Request. |
...
Lifecycle of the Measurement
...
When you start the app the sensor must be instantiated once. It is not possible to change the site name or the application name after this call.
Code Block | ||
---|---|---|
| ||
String site = ...; // will delivered by the measurement provider Spring appName = ...; // will delivered by the measurement provider SpringStreams sensor = SpringStreams.getInstance(site, appName, getApplicationContext()); |
...
Note |
---|
The site name and application name is specified by the operator of the measurement system. |
...
Implementation of the Adapter
...
Code Block | ||
---|---|---|
| ||
package de.spring.mobile; /** * This adapter must be used to support some players by the library. * * @see Meta * @see SpringStreams * @see SpringStreams#track(StreamAdapter, java.util.Map) * * @author <a href="mailto:support@spring.de">spring GmbH & Co.KG</a> */ public interface StreamAdapter { public interface Meta { public String getPlayerName(); public String getPlayerVersion(); public int getScreenWidth(); public int getScreenHeight(); } public Meta getMeta(); public int getPosition(); public int getDuration(); public int getWidth(); public int getHeight(); } |
...
Beginning of the Measurement
This chapter explains step by step how a streaming content is transferred to the library for the measurement.
Info |
---|
In the library an adapter for class android.widget.VideoView The source code for this implementation can be found in Appendix A and in the library. |
...
The following code block shows an example for the use of the library.
...
Then an NSDictionary is generated in order to formulate more detailed information about the stream. Therefore the attribute stream must always be specified
Info |
---|
The attribute |
...
Info |
---|
A stream is measured as long as the Activity is in the foreground. When the Activity goes into the background, the current status is transmitted to the measurement system and the measurement stops. If the stream should be measured again, when the application will come back to the foreground, the method |
End of the Measurement
After the measurement of a stream has been started, this stream is measured by the sensor. The measurement can be stopped by calling the method stop
on the stream object. All measurements will be automatically stopped by the library, when the application goes into the background.
Code Block | ||
---|---|---|
| ||
// start streaming measurement Stream *stream = sensor.track(adapter, atts); ... // stop measurement programmatically stream.stop(); |
...
Info |
---|
If the stream should be measured again, when the Activity comes to the foreground or after the method |
...
Ending the application
If the application is closed, the method unload
can be called. This call sends the current state of the measurements to the measuring system and then terminates all measurements. This method is automatically called by the library, when the application goes into the background.
Code Block | ||
---|---|---|
| ||
... sensor.unload(); |
Using the SpringStreamsActivity
In the library is a SpringStreamsActivity included, that can be used to largely automate the measurement. The source code of this class can be found in Appendix B and in the library.
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(); } } |
...