Skip to content
This repository has been archived by the owner on Jul 25, 2023. It is now read-only.

Commit

Permalink
Merge branch 'hotfix/2.15' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienChauvin committed Jun 18, 2018
2 parents 167ff65 + a93a335 commit 8e4910a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 114 deletions.
16 changes: 16 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,24 @@
- [ ] Updated libraries to the latest version
- [ ] Read through the README of the project

### Context description

```
INSERT PROJECT (Business Unit / project team) and a few words about your usage of the player
```

### Issue Description

```
INSERT DESCRIPTION HERE
```

#### Steps to reproduce the behaviour

```
INSERT STEPS HERE
```

##### Complete stacktrace output

```
Expand Down
115 changes: 2 additions & 113 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
SRG Media Player
### SRG Media Player ###
================

### Current version : 1.2.52 ###

Building
--------
* install Android Studio from http://developer.android.com/sdk/installing/studio.html (stable build)
* checkout the project from github
* plug a device in ADB debug mode
* select Run/Run 'demo'
* select your device

Device requirements
-------------------
* Android 4.0.3 or higher (API 15+)

Setup for a custom project
---------------

Add maven repository in build.gradle:

repositories {
maven {
url "http://maven.ecetest.rts.ch/content/groups/public/"
}
}

Then use:

```groovy
dependencies {
// ...
compile 'ch.srg.mediaplayer:srgmediaplayer:$LIB_VERSION@aar'
compile 'ch.srg.mediaplayer:segmentOverlay:$LIB_VERSION@aar'
compile 'ch.srg.mediaplayer:srgmediaplayer-extras:$LIB_VERSION@aar'
compile 'ch.srg.mediaplayer:srgmediaplayer-service:$LIB_VERSION@aar'
// Following three only for ChromeCast support (and srgmediaplayer-service use)
compile 'com.android.support:mediarouter-v7:$SUPPORT_VERSION'
compile 'com.google.android.gms:play-services-cast:$SUPPORT_VERSION'
// ...
}
```

Features
--------
* has multiple selectable player engines: Android internal, ExoPlayer and more
* audio and video
* basic controls: play/pause/stop/seek
* fluid rotation (stream continuity)
Expand All @@ -56,74 +12,8 @@ Features
* offer management of segments for a video. Display as smart overlays, control of streams through segments (segment-overlay module)
* support for URL rewriting

Roadmap
----------------
* Offer a full featured and customizable Activity or a lightweight Fragment to used in others app

* Offer a full featured playlist management. Display, navigation, business logic.

* Handle multiple formats: HLS, DASH, ...

* UI can be easily customized with Theme or full custom layouts

Implementation
-----------------
* The fist step for integrate the SRG Media Player in your project is to configure your own dataProvider for bind your model to the API. In the demo application we have build a DummyDataProvider to handle data from web and specific videos. The class implements basic interface for dataProvider, and segments.

```java
private static Map<String, String> data = new HashMap<String, String>() {
{
put("SPECIMEN", "http://stream-i.rts.ch/i/specm/2014/specm_20141203_full_f_817794-,101,701,1201,k.mp4.csmil/master.m3u8");
put("ODK", "http://stream-i.rts.ch/i/oreki/2015/OREKI_20150225_full_f_861302-,101,701,1201,k.mp4.csmil/master.m3u8");
put("BIDOUM", "http://stream-i.rts.ch/i/bidbi/2008/bidbi_01042008-,450,k.mp4.csmil/master.m3u8");
put("MULTI1", "https://srgssruni9ch-lh.akamaihd.net/i/enc9uni_ch@191320/master.m3u8");
put("MULTI2", "https://srgssruni10ch-lh.akamaihd.net/i/enc10uni_ch@191367/master.m3u8");
put("MULTI3", "https://srgssruni7ch-lh.akamaihd.net/i/enc7uni_ch@191283/master.m3u8");
put("MULTI4", "https://srgssruni11ch-lh.akamaihd.net/i/enc11uni_ch@191455/master.m3u8");
put("ERROR", "http://invalid.stream/");
};
};

@Override
public Uri getUri(String mediaIdentifier) {
if (mediaIdentifier.contains("@")){
mediaIdentifier = mediaIdentifier.substring(0,mediaIdentifier.indexOf('@'));
}
if (data.containsKey(mediaIdentifier)) {
return Uri.parse(data.get(mediaIdentifier));
}
return null;
}
```

* In this basic implementation if we ask to the player to play the Media with the identifier SPECIMEN the dataProvider will send back the correct Uri to the player.

* If you want to specify the media type you will play and set a delegate for it. You need to provide a PlayerDelegateFactory and set it to the player controller.

```java
playerDelegateFactory = new PlayerDelegateFactory() {
@Override
public PlayerDelegate getDelegateForMediaIdentifier(PlayerDelegate.OnPlayerDelegateListener srgMediaPlayer, String mediaIdentifier) {
switch (multiDataProvider.getPrefix(mediaIdentifier)) {
case "aac":
return new ExoPlayerDelegate(DemoApplication.this,srgMediaPlayer, ExoPlayerDelegate.SourceType.EXTRACTOR);
case "native":
return new NativePlayerDelegate(srgMediaPlayer);
}
return new NativePlayerDelegate(srgMediaPlayer);
}
};
srgMediaPlayerController.setPlayerDelegateFactory(playerDelegateFactory);
```

* In this example we configure a new PlayerDelegateFactory and specify the player delegate to use for each kind of prefix in our model. ExoPlayerDelegate for AAC and Native for other content.

* A default PlayerDelegateFactory is already implemented, we use ExoPlayer for JellyBean and HLS content and NativePlayer for versions before JellyBean.

* We have currently two delegates implemented, one for ExoPlayer and one for NativePlayer. You can create your custom delegate if you need to use a different kind of media player. Be sure to implement PlayerDelegate interface to handle communication between the player and the component.

Next step is to add the SRGMediaPlayerView in your layout.

```xml
<ch.srg.mediaplayer.SRGMediaPlayerView
android:id="@+id/demo_video_container"
Expand Down Expand Up @@ -176,7 +66,6 @@ In your Activity (or fragment) you have to coordinate all the view with the play
```java
private SRGMediaPlayerController srgMediaPlayerController;
private SRGMediaPlayerView videoContainer;
private MultiDataProvider dataProvider;
private LivePlayerControlView playerControlView;

...
Expand All @@ -189,7 +78,7 @@ In your Activity (or fragment) you have to coordinate all the view with the play
videoContainer = (SRGMediaPlayerView) findViewById(R.id.demo_video_container);
playerControlView = (LivePlayerControlView) findViewById(R.id.media_control);

srgMediaPlayerController = new SRGMediaPlayerController(this, dataProvider, PLAYER_TAG);
srgMediaPlayerController = new SRGMediaPlayerController(this, PLAYER_TAG);
srgMediaPlayerController.bindToMediaPlayerView(videoContainer);
playerControlView.attachToController(srgMediaPlayer);
srgMediaPlayerController.registerEventListener(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,8 @@ private Event(SRGMediaPlayerController controller, Type eventType, SRGMediaPlaye
mediaMuted = controller.muted;
mediaLive = controller.isLive();
mediaPlaylistStartTime = controller.getPlaylistStartTime();
videoViewDimension = controller.mediaPlayerView != null ? controller.mediaPlayerView.getVideoRenderingViewSizeString() : SRGMediaPlayerView.UNKNOWN_DIMENSION;
SRGMediaPlayerView mediaPlayerView = controller.mediaPlayerView;
videoViewDimension = mediaPlayerView != null ? mediaPlayerView.getVideoRenderingViewSizeString() : SRGMediaPlayerView.UNKNOWN_DIMENSION;
screenType = controller.getScreenType();
this.segment = segment;
this.blockingReason = blockingReason;
Expand Down Expand Up @@ -706,6 +707,7 @@ public boolean handleMessage(final Message msg) {
if (msg.what != MSG_PERIODIC_UPDATE) {
logV("handleMessage: " + msg);
}
final SRGMediaPlayerView mediaPlayerView = this.mediaPlayerView;
switch (msg.what) {
case MSG_PREPARE_FOR_URI:
setStateInternal(State.PREPARING);
Expand Down Expand Up @@ -1244,6 +1246,7 @@ public SRGMediaPlayerView getMediaPlayerView() {
}

private void internalUpdateMediaPlayerViewBound() {
final SRGMediaPlayerView mediaPlayerView = this.mediaPlayerView;
if (mediaPlayerView != null) {
if (!canRenderInView(mediaPlayerView.getVideoRenderingView())) {
// We need to create a new rendering view.
Expand All @@ -1270,6 +1273,7 @@ public void run() {
}

private void bindRenderingViewInUiThread() throws SRGMediaPlayerException {
SRGMediaPlayerView mediaPlayerView = this.mediaPlayerView;
if (mediaPlayerView == null ||
!canRenderInView(mediaPlayerView.getVideoRenderingView())) {
throw new SRGMediaPlayerException("ExoPlayer cannot render video in a "
Expand Down

0 comments on commit 8e4910a

Please sign in to comment.