Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
cpp
cpp
KMA_SpringStreams *spring = [KMA_SpringStreams getInstance:@"sitename" a:@"TestApplication"];

...

From this point on, the method getInstance must be used .

Code Block
cpp
cpp
KMA_SpringStreams *spring = [KMA_SpringStreams getInstance];

...

Info

In the library an adapter for class MPMoviePlayerController AVPlayerViewController from the MediaPlayer.framework AVKit ramework is settled.

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.

...

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
cpp
cpp
...
[[KMA_SpringStreams getInstance] unload];

...

Code Block
//
//  MediaPlayerAdapter.m
//  KMA_SpringStreams
//
//  Created by Frank Kammann on 26.08.11.
//  Copyright 2011 spring GmbH & Co. KG. All rights reserved.
//

#import <MediaPlayer/MediaPlayer.h>
#import <UIKit/UIKit.h>

#import "KMA_SpringStreams.h"


@class MediaPlayerMeta;


@implementation MediaPlayerAdapter

MPMoviePlayerController *controller;
NSObject<Meta> *meta;

- (id)adapter:(MPMoviePlayerController *)player {
    self = [super init:player];

    if (self) {
        meta = [[MediaPlayerMeta alloc] meta:player];
    }
    return self;
}

- (NSObject<Meta>*) getMeta {
    return meta;
}

- (int) getPosition {
    int position = (int)round([controller currentPlaybackTime]);
    // in initialize phase in controller this value is set to -2^31
    if(position < 0) position = 0;
    return position;
}


- (int) getDuration {
    return (int)round([controller duration]);
}

- (int) getWidth {
    return controller.view.bounds.size.width;
}

- (int) getHeight {
    return controller.view.bounds.size.height;
}

- (void)dealloc {
    [meta release];
    [super dealloc];
}


@end



@implementation MediaPlayerMeta

MPMoviePlayerController *controller;

- (id) meta:(MPMoviePlayerController *)player {
    self = [super init];
    if (self) {
        if(player == nil) 
            @throw [NSException exceptionWithName:@"IllegalArgumentException" 
                                           reason:@"player may not be null" 
                                         userInfo:nil];
        controller = player;
    }
    return self;
}

- (NSString*) getPlayerName {
    return @"MediaPlayer";
}

- (NSString*) getPlayerVersion {
    return [UIDevice currentDevice].systemVersion;
}

- (int) getScreenWidth {
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    return screenRect.size.width;
}

- (int) getScreenHeight {
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    return screenRect.size.height;
}

@end

...