This repository has been archived by the owner on Jul 25, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from SRGSSR/develop
Develop
- Loading branch information
Showing
7 changed files
with
157 additions
and
9 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
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
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
56 changes: 56 additions & 0 deletions
56
srgmediaplayer/src/main/java/ch/srg/mediaplayer/AudioTrack.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,56 @@ | ||
package ch.srg.mediaplayer; | ||
|
||
import android.support.annotation.Nullable; | ||
|
||
import com.google.android.exoplayer2.Format; | ||
import com.google.android.exoplayer2.source.TrackGroup; | ||
|
||
/** | ||
* Helper to manage ExoPlayer AudioTrack | ||
*/ | ||
public class AudioTrack { | ||
public final int groupIndex; | ||
public final int trackIndex; | ||
public final String trackId; | ||
public final String language; | ||
|
||
|
||
public AudioTrack(int groupIndex, int trackIndex, String trackId, String language) { | ||
this.groupIndex = groupIndex; | ||
this.trackIndex = trackIndex; | ||
this.trackId = trackId; | ||
this.language = language; | ||
} | ||
|
||
@Nullable | ||
public static AudioTrack createFrom(TrackGroup trackGroup, int groupIndex, int trackIndex) { | ||
Format format = trackGroup.getFormat(trackIndex); | ||
if (format.id != null && format.language != null) { | ||
return new AudioTrack(groupIndex, trackIndex, format.id, format.language); | ||
} else { | ||
return null; | ||
} | ||
} | ||
|
||
@Override | ||
public boolean equals(Object o) { | ||
if (this == o) return true; | ||
if (o == null || getClass() != o.getClass()) return false; | ||
|
||
AudioTrack that = (AudioTrack) o; | ||
|
||
if (trackIndex != that.trackIndex || groupIndex != that.groupIndex) return false; | ||
if (trackId != null ? !trackId.equals(that.trackId) : that.trackId != null) return false; | ||
return language != null ? language.equals(that.language) : that.language == null; | ||
|
||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = Integer.valueOf(groupIndex).hashCode(); | ||
result = 31 * result + Integer.valueOf(trackIndex).hashCode(); | ||
result = 31 * result + (trackId != null ? trackId.hashCode() : 0); | ||
result = 31 * result + (language != null ? language.hashCode() : 0); | ||
return result; | ||
} | ||
} |
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
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
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