-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6634837
Showing
76 changed files
with
1,487 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
*.iml | ||
.gradle | ||
/local.properties | ||
/.idea/workspace.xml | ||
/.idea/libraries | ||
.DS_Store | ||
/build | ||
/captures | ||
.externalNativeBuild | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
apply plugin: 'com.android.application' | ||
|
||
android { | ||
compileSdkVersion 25 | ||
buildToolsVersion "25.0.2" | ||
|
||
defaultConfig { | ||
applicationId "com.bitmovin.player.samples.casting.basic" | ||
minSdkVersion 16 | ||
targetSdkVersion 25 | ||
versionCode 1 | ||
versionName "1.0" | ||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||
} | ||
buildTypes { | ||
release { | ||
minifyEnabled false | ||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||
} | ||
} | ||
} | ||
|
||
dependencies { | ||
compile fileTree(dir: 'libs', include: ['*.jar']) | ||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { | ||
exclude group: 'com.android.support', module: 'support-annotations' | ||
}) | ||
compile 'com.android.support:appcompat-v7:25.3.1' | ||
compile 'com.android.support.constraint:constraint-layout:1.0.0-alpha8' | ||
testCompile 'junit:junit:4.12' | ||
|
||
compile 'com.bitmovin.player:playercore:1.0.0' | ||
|
||
compile 'com.google.android.libraries.cast.companionlibrary:ccl:2.9.1' //only needed if Chromecast is used | ||
compile 'com.android.support:mediarouter-v7:25.3.1' //only needed if Chromecast is used | ||
} |
Empty file.
28 changes: 28 additions & 0 deletions
28
...c/androidTest/java/com/bitmovin/player/samples/casting/basic/ExampleInstrumentedTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.bitmovin.player.samples.casting.basic; | ||
|
||
import android.content.Context; | ||
import android.support.test.InstrumentationRegistry; | ||
import android.support.test.runner.AndroidJUnit4; | ||
|
||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
/** | ||
* Instrumentation test, which will execute on an Android device. | ||
* | ||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
*/ | ||
@RunWith(AndroidJUnit4.class) | ||
public class ExampleInstrumentedTest | ||
{ | ||
@Test | ||
public void useAppContext() throws Exception | ||
{ | ||
// Context of the app under test. | ||
Context appContext = InstrumentationRegistry.getTargetContext(); | ||
|
||
assertEquals("com.bitmovin.player.samples.casting.basic", appContext.getPackageName()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
package="com.bitmovin.player.samples.casting.basic"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
|
||
<application | ||
android:name=".SampleApplication" | ||
android:allowBackup="true" | ||
android:icon="@mipmap/ic_launcher" | ||
android:label="@string/app_name" | ||
android:supportsRtl="true" | ||
android:theme="@style/AppTheme"> | ||
|
||
<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" /> | ||
|
||
<meta-data | ||
android:name="BITMOVIN_PLAYER_LICENSE_KEY" | ||
android:value="" /> | ||
|
||
<!-- Following lines are needed for the usage of cast --> | ||
|
||
<receiver android:name="com.google.android.libraries.cast.companionlibrary.remotecontrol.VideoIntentReceiver" /> | ||
<service android:name="com.google.android.libraries.cast.companionlibrary.notification.VideoCastNotificationService" /> | ||
|
||
<activity | ||
android:name="com.google.android.libraries.cast.companionlibrary.cast.player.VideoCastControllerActivity" | ||
android:screenOrientation="portrait" | ||
android:label="@string/app_name" | ||
android:launchMode="singleTask" | ||
android:theme="@style/NoActionBar"> | ||
<intent-filter> | ||
<action android:name="android.intent.action.MAIN" /> | ||
</intent-filter> | ||
</activity> | ||
|
||
|
||
</application> | ||
|
||
</manifest> |
134 changes: 134 additions & 0 deletions
134
BasicCasting/src/main/java/com/bitmovin/player/samples/casting/basic/MainActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
package com.bitmovin.player.samples.casting.basic; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.os.Bundle; | ||
import android.support.annotation.LayoutRes; | ||
import android.support.annotation.NonNull; | ||
import android.support.annotation.Nullable; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.view.LayoutInflater; | ||
import android.view.View; | ||
import android.view.ViewGroup; | ||
import android.widget.AdapterView; | ||
import android.widget.ArrayAdapter; | ||
import android.widget.ListView; | ||
import android.widget.TextView; | ||
|
||
import com.bitmovin.player.cast.CastManager; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class MainActivity extends AppCompatActivity | ||
{ | ||
private ListView listView; | ||
private ListAdapter listAdapter; | ||
private CastManager castManager; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) | ||
{ | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_main); | ||
|
||
//Setup ListView, ListAdapter and the ListItems | ||
List<ListItem> exampleListItems = getExampleListItems(); | ||
this.listView = (ListView) findViewById(R.id.listview); | ||
this.listAdapter = new ListAdapter(this, 0, exampleListItems); | ||
this.listView.setAdapter(this.listAdapter); | ||
this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener() | ||
{ | ||
@Override | ||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) | ||
{ | ||
onListItemClicked((ListItem) parent.getItemAtPosition(position)); | ||
} | ||
}); | ||
|
||
// Retrieving the instance of the CastManager | ||
this.castManager = CastManager.getInstance(); | ||
} | ||
|
||
|
||
@Override | ||
protected void onResume() | ||
{ | ||
super.onResume(); | ||
|
||
// The CastManager must know if the app is visible, in order to start the notification service. | ||
// Call incrementUiCounter on the cast manager in every onResume of your activities | ||
this.castManager.incrementUiCounter(); | ||
} | ||
|
||
@Override | ||
protected void onPause() | ||
{ | ||
// The CastManager must know if the app is visible, in order to start the notification service. | ||
// Call incrementUiCounter on the cast manager in every onResume of your activities | ||
this.castManager.decrementUiCounter(); | ||
|
||
super.onPause(); | ||
} | ||
|
||
private void onListItemClicked(ListItem item) | ||
{ | ||
Intent playerIntent = new Intent(this, PlayerActivity.class); | ||
playerIntent.putExtra(PlayerActivity.SOURCE_URL, item.getUrl()); | ||
playerIntent.putExtra(PlayerActivity.SOURCE_TITLE, item.getTitle()); | ||
startActivity(playerIntent); | ||
} | ||
|
||
private List<ListItem> getExampleListItems() | ||
{ | ||
List<ListItem> items = new ArrayList<ListItem>(); | ||
items.add(new ListItem("Sintel", "http://bitdash-a.akamaihd.net/content/sintel/sintel.mpd")); | ||
items.add(new ListItem("Art of Motion", "https://bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd")); | ||
return items; | ||
} | ||
|
||
private static class ListItem | ||
{ | ||
private String title; | ||
private String url; | ||
|
||
public ListItem(String title, String url) | ||
{ | ||
this.title = title; | ||
this.url = url; | ||
} | ||
|
||
public String getTitle() | ||
{ | ||
return title; | ||
} | ||
|
||
public String getUrl() | ||
{ | ||
return url; | ||
} | ||
} | ||
|
||
private static final class ListAdapter extends ArrayAdapter<ListItem> | ||
{ | ||
public ListAdapter(@NonNull Context context, @LayoutRes int resource, @NonNull List<ListItem> objects) | ||
{ | ||
super(context, resource, objects); | ||
} | ||
|
||
@NonNull | ||
@Override | ||
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) | ||
{ | ||
View view = convertView; | ||
|
||
if (view == null) | ||
{ | ||
view = LayoutInflater.from(getContext()).inflate(android.R.layout.simple_list_item_1, parent, false); | ||
} | ||
|
||
((TextView) view).setText(getItem(position).getTitle()); | ||
return view; | ||
} | ||
} | ||
} |
85 changes: 85 additions & 0 deletions
85
BasicCasting/src/main/java/com/bitmovin/player/samples/casting/basic/PlayerActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
package com.bitmovin.player.samples.casting.basic; | ||
|
||
import android.os.Bundle; | ||
import android.support.v7.app.AppCompatActivity; | ||
|
||
import com.bitmovin.player.BitmovinPlayer; | ||
import com.bitmovin.player.BitmovinPlayerView; | ||
import com.bitmovin.player.cast.CastManager; | ||
import com.bitmovin.player.config.PlayerConfiguration; | ||
import com.bitmovin.player.config.media.SourceConfiguration; | ||
import com.bitmovin.player.config.media.SourceItem; | ||
|
||
public class PlayerActivity extends AppCompatActivity | ||
{ | ||
public static final String SOURCE_URL = "SOURCE_URL"; | ||
public static final String SOURCE_TITLE = "SOURCE_TITLE"; | ||
|
||
private BitmovinPlayerView bitmovinPlayerView; | ||
private BitmovinPlayer bitmovinPlayer; | ||
|
||
private CastManager castManager; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) | ||
{ | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_player); | ||
|
||
String sourceUrl = getIntent().getStringExtra(SOURCE_URL); | ||
String sourceTitle = getIntent().getStringExtra(SOURCE_TITLE); | ||
if (sourceUrl == null || sourceTitle == null) | ||
{ | ||
finish(); | ||
} | ||
|
||
this.castManager = CastManager.getInstance(); | ||
this.bitmovinPlayerView = (BitmovinPlayerView) this.findViewById(R.id.bitmovinPlayerView); | ||
this.bitmovinPlayer = this.bitmovinPlayerView.getPlayer(); | ||
|
||
this.initializePlayer(sourceUrl, sourceTitle); | ||
} | ||
|
||
@Override | ||
protected void onResume() | ||
{ | ||
super.onResume(); | ||
this.bitmovinPlayerView.onResume(); | ||
//The cast manager must know about the ui state, in order to start the notification service | ||
//Call incrementUiCounter on the cast manager in every onResume of your activities | ||
this.castManager.incrementUiCounter(); | ||
} | ||
|
||
@Override | ||
protected void onPause() | ||
{ | ||
//The cast manager must know about the ui state, in order to start the notification service | ||
//Call decrementUiCounter on the cast manager in every onPause of your activities | ||
this.castManager.decrementUiCounter(); | ||
this.bitmovinPlayerView.onPause(); | ||
super.onPause(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() | ||
{ | ||
this.bitmovinPlayerView.onDestroy(); | ||
super.onDestroy(); | ||
} | ||
|
||
protected void initializePlayer(String sourceUrl, String sourceTitle) | ||
{ | ||
// Create a new source configuration | ||
SourceConfiguration sourceConfiguration = new SourceConfiguration(); | ||
|
||
// Create a new source item | ||
SourceItem sourceItem = new SourceItem(sourceUrl); | ||
sourceItem.setTitle(sourceTitle); | ||
|
||
// Add source item to source configuration | ||
sourceConfiguration.addSourceItem(sourceItem); | ||
|
||
// load source using the created source configuration | ||
this.bitmovinPlayer.load(sourceConfiguration); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
BasicCasting/src/main/java/com/bitmovin/player/samples/casting/basic/SampleApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.bitmovin.player.samples.casting.basic; | ||
|
||
import android.app.Application; | ||
|
||
import com.bitmovin.player.cast.CastManager; | ||
|
||
public class SampleApplication extends Application | ||
{ | ||
@Override | ||
public void onCreate() | ||
{ | ||
super.onCreate(); | ||
|
||
//The cast manager has to be initialized in the Application context, in order to work properly. | ||
CastManager.initialize(this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
tools:context="com.bitmovin.player.samples.casting.basic.MainActivity"> | ||
|
||
<ListView | ||
android:id="@+id/listview" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_alignParentTop="true"/> | ||
|
||
<!-- The MiniPlayer that shows up at the bottom of the activity if a cast is running --> | ||
<!-- Notice the app:auto_setup=true, which registers the miniplayer in the cast manager for you --> | ||
<com.google.android.libraries.cast.companionlibrary.widgets.MiniController | ||
android:id="@+id/miniController" | ||
android:layout_width="fill_parent" | ||
android:layout_height="wrap_content" | ||
android:layout_alignParentBottom="true" | ||
android:visibility="gone" | ||
app:auto_setup="true"/> | ||
|
||
</RelativeLayout> |
Oops, something went wrong.