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

Fixed seek video when played in full screen, and fixed background playing of video after exiting full screen #19

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Fri Jan 25 23:18:09 CST 2019
#Thu Jul 25 17:42:57 IST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.1.1-all.zip
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ public void onPaused(float seconds) {
vimeoReplayButton.setVisibility(View.GONE);
vimeoPauseButton.setVisibility(View.GONE);
vimeoPlayButton.setVisibility(View.VISIBLE);
//Log.d("TAG","OnPauseCall");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.ct7ct7ct7.androidvimeoplayer.R;
import com.ct7ct7ct7.androidvimeoplayer.listeners.VimeoPlayerReadyListener;
Expand Down Expand Up @@ -45,6 +47,7 @@ public class VimeoPlayerActivity extends AppCompatActivity {
private boolean loop;
private float aspectRatio;
private String orientation;
private static Float currentTime;

public static Intent createIntent(Context context, String orientation, VimeoPlayerView vimeoPlayerView) {
Intent intent = new Intent(context, VimeoPlayerActivity.class);
Expand All @@ -56,17 +59,22 @@ public static Intent createIntent(Context context, String orientation, VimeoPlay
intent.putExtra(EXTRA_TOPIC_COLOR, vimeoPlayerView.getTopicColor());
intent.putExtra(EXTRA_LOOP, vimeoPlayerView.getLoop());
intent.putExtra(EXTRA_ASPECT_RATIO, vimeoPlayerView.defaultOptions.aspectRatio);
currentTime=vimeoPlayerView.getCurrentTimeSeconds();
return intent;
}


@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

//Log.d("CurrentTime:-","LandscapeMode:-"+currentTime);
orientation = getIntent().getStringExtra(EXTRA_ORIENTATION);
if (REQUEST_ORIENTATION_PORTRAIT.equals(orientation)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
} else if (REQUEST_ORIENTATION_LANDSCAPE.equals(orientation)) {
// Log.e("CurrentTime:-",vimeoPlayerView.getCurrentTimeSeconds()+"");

//Toast.makeText(this, "LandscapeMode", Toast.LENGTH_SHORT).show();
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

Expand All @@ -88,8 +96,9 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
vimeoPlayerView.addReadyListener(new VimeoPlayerReadyListener() {
@Override
public void onReady(String title, float duration, TextTrack[] textTrackArray) {
//Log.d("VimeoPlayerActivity",startAt+"");
vimeoPlayerView.seekTo(startAt);
vimeoPlayerView.playTwoStage();
//vimeoPlayerView.playTwoStage();
}

@Override
Expand All @@ -108,6 +117,7 @@ public void onCurrentSecond(float second) {
vimeoPlayerView.setFullscreenClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Log.d("TAG","fullScreenClicked");
onBackPressed();
}
});
Expand All @@ -126,7 +136,13 @@ public void onBackPressed() {
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
if (REQUEST_ORIENTATION_AUTO.equals(orientation)) {

Float a=vimeoPlayerView.getCurrentTimeSeconds();

if (REQUEST_ORIENTATION_LANDSCAPE.equals(orientation)) {
vimeoPlayerView.seekTo(currentTime);
vimeoPlayerView.play();
// Toast.makeText(this, "currentTime:-"+a, Toast.LENGTH_SHORT).show();
vimeoPlayerView.reset();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.graphics.Color;
import android.graphics.PorterDuff;
import android.os.Build;
import android.os.Handler;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.View;
Expand Down Expand Up @@ -44,6 +45,7 @@ public class VimeoPlayerView extends FrameLayout implements LifecycleObserver {
private String baseUrl;
private boolean played = false;
private TextTrack[] textTracks;
private Handler handler = new Handler();


public VimeoPlayerView(Context context) {
Expand All @@ -63,7 +65,13 @@ public VimeoPlayerView(Context context, AttributeSet attrs, int defStyleAttr) {
public void onReady(String t, float duration, TextTrack[] textTrackArray) {
title = t;
textTracks = textTrackArray;
progressBar.setVisibility(View.GONE);

handler.postDelayed(new Runnable() {
public void run() {
progressBar.setVisibility(View.GONE);
}
}, 5000);

if (!defaultOptions.originalControls) {
if (defaultOptions.autoPlay) {
vimeoPlayer.playTwoStage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.util.Log
import android.widget.Toast
import com.ct7ct7ct7.androidvimeoplayer.model.PlayerState
import com.ct7ct7ct7.androidvimeoplayer.view.VimeoPlayerActivity
import com.ct7ct7ct7.androidvimeoplayersample.R
Expand All @@ -15,8 +17,10 @@ class FullscreenActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_fullscreen)

setupToolbar()
setupView()
// Toast.makeText(this,"OnCreateCalled",Toast.LENGTH_SHORT).show()
}

private fun setupToolbar() {
Expand All @@ -32,8 +36,12 @@ class FullscreenActivity : AppCompatActivity() {
vimeoPlayer.setFullscreenVisibility(true)

vimeoPlayer.setFullscreenClickListener {
var requestOrientation = VimeoPlayerActivity.REQUEST_ORIENTATION_AUTO
var requestOrientation = VimeoPlayerActivity.REQUEST_ORIENTATION_LANDSCAPE

//Log.d("FullscreenActivity",""+vimeoPlayer.currentTimeSeconds)
//vimeoPlayer.seekTo(vimeoPlayer.currentTimeSeconds)
startActivityForResult(VimeoPlayerActivity.createIntent(this, requestOrientation, vimeoPlayer), REQUEST_CODE)

}
}

Expand All @@ -43,11 +51,15 @@ class FullscreenActivity : AppCompatActivity() {
if (resultCode == Activity.RESULT_OK && requestCode == REQUEST_CODE) {
var playAt = data!!.getFloatExtra(VimeoPlayerActivity.RESULT_STATE_VIDEO_PLAY_AT, 0f)
vimeoPlayer.seekTo(playAt)
// Toast.makeText(this,"CurrentTime"+playAt,Toast.LENGTH_SHORT).show()

var playerState = PlayerState.valueOf(data!!.getStringExtra(VimeoPlayerActivity.RESULT_STATE_PLAYER_STATE))
//Log.e("PlayerState",""+playerState)
when (playerState) {
PlayerState.PLAYING -> vimeoPlayer.play()
PlayerState.PLAYING -> vimeoPlayer.pause()
PlayerState.PAUSED -> vimeoPlayer.pause()
PlayerState.UNKNOWN -> vimeoPlayer.pause()

}
}
}
Expand Down