Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/and orch yospace #19

Draft
wants to merge 13 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "orchestrator/android/ExoPlayer-Yospace-Java/ssp"]
path = orchestrator/android/ExoPlayer-Yospace-Java/ssp
url = [email protected]:streamroot/streamroot-samples-private.git
3 changes: 2 additions & 1 deletion orchestrator/android/AllSamples/settings.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
def samples = [
'ExoPlayer',
'ExoPlayer-Java',
'PRESTOplay-Java'
'PRESTOplay-Java',
'ExoPlayer-Yospace-Java'
]

samples.each {
Expand Down
10 changes: 10 additions & 0 deletions orchestrator/android/ExoPlayer-Yospace-Java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.iml
.gradle
/local.properties
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
.DS_Store
/build
/captures
.externalNativeBuild
34 changes: 34 additions & 0 deletions orchestrator/android/ExoPlayer-Yospace-Java/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Streamroot Android Orchestrator ExoPlayer Yospace Java

## Common integration

Make sure you start with the [common Java integration](https://github.com/streamroot/streamroot-samples/blob/master/orchestrator/android/README.md)

## Specific integration override

### 3. Bridge between your Player and the delivery client.

In order to work perfectly, the SDK instances need to interact with the player and listen to its events.
Please add the following class to your project :

- [PlayerInteractor](https://github.com/streamroot/streamroot-samples/blob/master/orchestrator/android/ExoPlayer-Yospace-Java/app/src/main/java/io/streamroot/lumen/delivery/client/samples/orchestrator/exoplayer/ExoPlayerInteractor.java)

## Additional steps

-> ExoPlayer requires targetCompatibility java 8.
-> URLs are hardcoded in the YospaceModule and mode is hardcoded in PlayerActivity

```java
private static final Session.PlaybackMode YOSPACE_MODE = Session.PlaybackMode.LIVE;
```

-> Some files are private and thus symlinked. You can find the missing files (AARs, adapters, policy impl, etc), inside the Yospace SDK sample application.

## Integrate with PRESTOplay

- [PRESTOplay-Java project](https://github.com/streamroot/streamroot-samples/tree/master/orchestrator/android/PRESTOplay-Java)

In particular, make sure you replace the player interactor by PRESTO's :

- [PlayerInteractor](https://github.com/streamroot/streamroot-samples/blob/master/orchestrator/android/PRESTOplay-Java/app/src/main/java/io/streamroot/lumen/delivery/client/samples/orchestrator/prestoplay/PRESTOPlayerInteractor.java)

1 change: 1 addition & 0 deletions orchestrator/android/ExoPlayer-Yospace-Java/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/build
46 changes: 46 additions & 0 deletions orchestrator/android/ExoPlayer-Yospace-Java/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//noinspection GradleCompatible
apply plugin: 'com.android.application'

android {
compileSdkVersion 29
defaultConfig {
applicationId "io.streamroot.lumen.delivery.client.samples.orchestrator.exoplayer"
minSdkVersion 19
targetSdkVersion 29
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}

compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
}

repositories {
flatDir {
dirs 'libs'
}
}

dependencies {
implementation 'com.google.android.exoplayer:exoplayer:2.11.7'

def dc_version = '1.1.1'
implementation 'io.streamroot.lumen.delivery.client:orchestrator-sdk:' + dc_version
implementation 'io.streamroot.lumen.delivery.client:orchestrator-sdk-utils:' + dc_version

implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

implementation(name: 'yoAdManagement-debug', ext: 'aar')
implementation(name: 'yoUtil-debug', ext: 'aar')
}
21 changes: 21 additions & 0 deletions orchestrator/android/ExoPlayer-Yospace-Java/app/proguard-rules.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="io.streamroot.lumen.delivery.client.samples.orchestrator.exoplayer">

<application
android:name=".SRApplication"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"
tools:ignore="AllowBackup,GoogleAppIndexingWarning">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".PlayerActivity"
android:label="@string/title_activity_player"
android:theme="@style/AppTheme.NoActionBar" />

<meta-data
android:name="io.streamroot.lumen.delivery.client.DeliveryClientKey"
android:value="demoswebsiteandpartners" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.streamroot.lumen.delivery.client.samples.orchestrator.exoplayer;

public interface Callback1<T> {
void call(T t);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package io.streamroot.lumen.delivery.client.samples.orchestrator.exoplayer;

import androidx.annotation.NonNull;

import com.google.android.exoplayer2.ExoPlaybackException;
import com.google.android.exoplayer2.ExoPlayer;
import com.google.android.exoplayer2.Player;
import com.google.android.exoplayer2.Player.EventListener;
import com.google.android.exoplayer2.source.TrackGroupArray;
import com.google.android.exoplayer2.trackselection.TrackSelectionArray;

import java.util.concurrent.atomic.AtomicBoolean;

import io.streamroot.lumen.delivery.client.core.LumenPlayerInteractorBase;
import io.streamroot.lumen.delivery.client.core.LumenVideoPlaybackState;

public final class ExoPlayerInteractor extends LumenPlayerInteractorBase implements EventListener {

private AtomicBoolean listening = new AtomicBoolean(false);

public ExoPlayerInteractor() {}
public ExoPlayerInteractor(@NonNull ExoPlayer exoPlayer) { setPlayer(exoPlayer); }

public void setPlayer(@NonNull ExoPlayer exoPlayer) {
if (listening.compareAndSet(false, true)) {
exoPlayer.addListener(this);
}
}

@Override
public void onSeekProcessed() {
super.playerStateChange(LumenVideoPlaybackState.SEEKING);
}

@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
super.playerTrackSwitch();
}

@Override
public void onPlayerError(ExoPlaybackException error) {
super.playerError();
}

@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
switch(playbackState) {
case Player.STATE_IDLE:
super.playerStateChange(LumenVideoPlaybackState.IDLE);
break;
case Player.STATE_BUFFERING:
super.playerStateChange(LumenVideoPlaybackState.REBUFFERING);
break;
case Player.STATE_READY:
super.playerStateChange(playWhenReady ? LumenVideoPlaybackState.PLAYING : LumenVideoPlaybackState.PAUSED);
break;
case Player.STATE_ENDED:
super.playerStateChange(LumenVideoPlaybackState.ENDED);
break;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.streamroot.lumen.delivery.client.samples.orchestrator.exoplayer;

import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

findViewById(R.id.launchButton).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final String stream = ((TextView)findViewById(R.id.streamEditText)).getText().toString();
if (TextUtils.isEmpty(stream.trim())) return;

final Intent i = PlayerActivity.makeIntent(MainActivity.this,
new PlayerActivity.PlayerActivityArgs(
((TextView)findViewById(R.id.dcKeyET)).getText().toString(),
stream,
((TextView)findViewById(R.id.orchPropET)).getText().toString()
)
).addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(i);
}
});
}
}
Loading