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

Replace video player by ExoPlayer #8132

Merged
merged 1 commit into from
Jun 9, 2021
Merged
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,8 @@ dependencies {
ktlint "com.pinterest:ktlint:0.41.0"
implementation 'org.conscrypt:conscrypt-android:2.5.2'

implementation 'com.google.android.exoplayer:exoplayer:2.13.2'

// Shimmer animation
implementation 'com.elyeproj.libraries:loaderviewlibrary:2.0.0'

Expand Down
2 changes: 1 addition & 1 deletion scripts/analysis/lint-results.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
DO NOT TOUCH; GENERATED BY DRONE
<span class="mdl-layout-title">Lint Report: 228 warnings</span>
<span class="mdl-layout-title">Lint Report: 227 warnings</span>
2 changes: 1 addition & 1 deletion src/main/java/com/nextcloud/client/media/Player.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ internal class Player(
private var enqueuedFile: PlaylistItem? = null

private var playedFile: OCFile? = null
private var startPositionMs: Int = 0
private var startPositionMs: Long = 0
private var autoPlay = true
private var user: User? = null
private var dataSource: String? = null
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nextcloud/client/media/PlayerService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ class PlayerService : Service() {
private fun onActionPlay(intent: Intent) {
val user: User = intent.getParcelableExtra(EXTRA_USER) as User
val file: OCFile = intent.getParcelableExtra(EXTRA_FILE) as OCFile
val startPos = intent.getIntExtra(EXTRA_START_POSITION_MS, 0)
val startPos = intent.getLongExtra(EXTRA_START_POSITION_MS, 0)
val autoPlay = intent.getBooleanExtra(EXTRA_AUTO_PLAY, true)
val item = PlaylistItem(file = file, startPositionMs = startPos, autoPlay = autoPlay, user = user)
player.play(item)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PlayerServiceConnection(private val context: Context) : MediaController.Me
}
}

fun start(user: User, file: OCFile, playImmediately: Boolean, position: Int) {
fun start(user: User, file: OCFile, playImmediately: Boolean, position: Long) {
val i = Intent(context, PlayerService::class.java)
i.putExtra(PlayerService.EXTRA_USER, user)
i.putExtra(PlayerService.EXTRA_FILE, file)
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/nextcloud/client/media/PlaylistItem.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ package com.nextcloud.client.media
import com.nextcloud.client.account.User
import com.owncloud.android.datamodel.OCFile

data class PlaylistItem(val file: OCFile, val startPositionMs: Int, val autoPlay: Boolean, val user: User)
data class PlaylistItem(val file: OCFile, val startPositionMs: Long, val autoPlay: Boolean, val user: User)
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@
import org.parceler.Parcels;

import java.io.File;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down Expand Up @@ -560,7 +559,7 @@ private Fragment chooseInitialSecondFragment(OCFile file, User user) {
Fragment secondFragment = null;
if (file != null && !file.isFolder()) {
if (file.isDown() && PreviewMediaFragment.canBePreviewed(file)) {
int startPlaybackPosition = getIntent().getIntExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
long startPlaybackPosition = getIntent().getLongExtra(PreviewVideoActivity.EXTRA_START_POSITION, 0);
boolean autoplay = getIntent().getBooleanExtra(PreviewVideoActivity.EXTRA_AUTOPLAY, true);
secondFragment = PreviewMediaFragment.newInstance(file, user, startPlaybackPosition, autoplay);
} else if (file.isDown() && PreviewTextFileFragment.canBePreviewed(file)) {
Expand Down Expand Up @@ -846,7 +845,8 @@ public boolean onOptionsItemSelected(MenuItem item) {
second != null && second.getFile() != null ||
isSearchOpen()) {
onBackPressed();
} else if (getLeftFragment() instanceof FileDetailFragment) {
} else if (getLeftFragment() instanceof FileDetailFragment ||
getLeftFragment() instanceof PreviewMediaFragment) {
onBackPressed();
} else {
openDrawer();
Expand Down Expand Up @@ -1899,7 +1899,7 @@ private void onRenameFileOperationFinish(RenameFileOperation operation,
renamedFile.equals(details.getFile())) {
((PreviewMediaFragment) details).updateFile(renamedFile);
if (PreviewMediaFragment.canBePreviewed(renamedFile)) {
int position = ((PreviewMediaFragment) details).getPosition();
long position = ((PreviewMediaFragment) details).getPosition();
startMediaPreview(renamedFile, position, true, true, true);
} else {
getFileOperationsHelper().openFile(renamedFile);
Expand Down Expand Up @@ -2183,12 +2183,13 @@ public void startImagePreview(OCFile file, VirtualFolderType type, boolean showP
* Stars the preview of an already down media {@link OCFile}.
*
* @param file Media {@link OCFile} to preview.
* @param startPlaybackPosition Media position where the playback will be started,
* in milliseconds.
* @param autoplay When 'true', the playback will start without user
* interactions.
* @param startPlaybackPosition Media position where the playback will be started, in milliseconds.
* @param autoplay When 'true', the playback will start without user interactions.
*/
public void startMediaPreview(OCFile file, int startPlaybackPosition, boolean autoplay, boolean showPreview,
public void startMediaPreview(OCFile file,
long startPlaybackPosition,
boolean autoplay,
boolean showPreview,
boolean streamMedia) {
Optional<User> user = getUser();
if (!user.isPresent()) {
Expand Down Expand Up @@ -2363,7 +2364,7 @@ public void onMessageEvent(SyncEventFinished event) {
startTextPreview((OCFile) bundle.get(EXTRA_FILE), true);
} else if (bundle.containsKey(PreviewVideoActivity.EXTRA_START_POSITION)) {
startMediaPreview((OCFile) bundle.get(EXTRA_FILE),
(int) bundle.get(PreviewVideoActivity.EXTRA_START_POSITION),
(long) bundle.get(PreviewVideoActivity.EXTRA_START_POSITION),
(boolean) bundle.get(PreviewVideoActivity.EXTRA_AUTOPLAY), true, true);
} else if (bundle.containsKey(PreviewImageActivity.EXTRA_VIRTUAL_TYPE)) {
startImagePreview((OCFile)bundle.get(EXTRA_FILE),
Expand Down
Loading