Merge pull request #65 from sschueller/develop

Release v1.0.14
This commit is contained in:
Stefan Schüller 2018-12-26 16:32:21 +01:00 committed by GitHub
commit ec7a3b4ffa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 165 additions and 65 deletions

View File

@ -6,8 +6,8 @@ android {
applicationId "net.schueller.peertube"
minSdkVersion 21
targetSdkVersion 28
versionCode 1013
versionName "1.0.13"
versionCode 1014
versionName "1.0.14"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])

View File

@ -38,6 +38,7 @@ import net.schueller.peertube.model.VideoList;
import net.schueller.peertube.network.GetVideoDataService;
import net.schueller.peertube.network.RetrofitInstance;
import net.schueller.peertube.provider.SearchSuggestionsProvider;
import net.schueller.peertube.service.VideoPlayerService;
import java.util.ArrayList;
@ -151,6 +152,11 @@ public class VideoListActivity extends AppCompatActivity {
return true;
}
@Override
protected void onDestroy() {
super.onDestroy();
stopService(new Intent(this, VideoPlayerService.class));
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {

View File

@ -7,7 +7,7 @@ import android.view.ViewGroup;
import android.widget.TextView;
import com.google.android.material.bottomsheet.BottomSheetDialogFragment;
import com.mikepenz.iconics.Iconics;
import net.schueller.peertube.R;
import net.schueller.peertube.service.VideoPlayerService;
@ -17,6 +17,11 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
private static VideoPlayerService videoPlayerService;
private TextView speed05Icon;
private TextView speed10Icon;
private TextView speed15Icon;
private TextView speed20Icon;
public static VideoOptionsFragment newInstance(VideoPlayerService mService) {
videoPlayerService = mService;
return new VideoOptionsFragment();
@ -31,21 +36,43 @@ public class VideoOptionsFragment extends BottomSheetDialogFragment {
View view = inflater.inflate(R.layout.bottom_sheet_video_options_fragment, container,
false);
// get the views and attach the listener
// Icons
speed05Icon = view.findViewById(R.id.video_speed05_icon);
speed10Icon = view.findViewById(R.id.video_speed10_icon);
speed15Icon = view.findViewById(R.id.video_speed15_icon);
speed20Icon = view.findViewById(R.id.video_speed20_icon);
//Playback speed buttons
// Buttons
TextView speed05 = view.findViewById(R.id.video_speed05);
TextView speed10 = view.findViewById(R.id.video_speed10);
TextView speed15 = view.findViewById(R.id.video_speed15);
TextView speed20 = view.findViewById(R.id.video_speed20);
//Playback speed controls
speed05.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(0.5f));
speed10.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.0f));
speed15.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(1.5f));
speed20.setOnClickListener(v -> videoPlayerService.setPlayBackSpeed(2.0f));
// Default
setVideoSpeed(1.0f, speed10Icon);
// Attach the listener
speed05.setOnClickListener(v -> setVideoSpeed(0.5f, speed05Icon));
speed10.setOnClickListener(v -> setVideoSpeed(1.0f, speed10Icon));
speed15.setOnClickListener(v -> setVideoSpeed(1.5f, speed15Icon));
speed20.setOnClickListener(v -> setVideoSpeed(2.0f, speed20Icon));
return view;
}
private void setVideoSpeed(Float speed, TextView icon) {
speed05Icon.setText("");
speed10Icon.setText("");
speed15Icon.setText("");
speed20Icon.setText("");
videoPlayerService.setPlayBackSpeed(speed);
icon.setText(R.string.video_speed_active_icon);
new Iconics.IconicsBuilder().ctx(getContext()).on(icon).build();
}
}

View File

@ -37,6 +37,8 @@ import static net.schueller.peertube.activity.VideoListActivity.EXTRA_VIDEOID;
public class VideoPlayerService extends Service {
private static final String TAG = "VideoPlayerService";
private final IBinder mBinder = new LocalBinder();
private static final String PLAYBACK_CHANNEL_ID = "playback_channel";
@ -64,12 +66,12 @@ public class VideoPlayerService extends Service {
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {
if (playbackState == ACTION_PAUSE) { // this means that pause is available, hence the audio is playing
Log.v("VideoPlayerService", "ACTION_PLAY: " + playbackState);
Log.v(TAG, "ACTION_PLAY: " + playbackState);
registerReceiver(myNoisyAudioStreamReceiver, becomeNoisyIntentFilter);
}
if (playbackState == ACTION_PLAY) { // this means that play is available, hence the audio is paused or stopped
Log.v("VideoPlayerService", "ACTION_PAUSE: " + playbackState);
Log.v(TAG, "ACTION_PAUSE: " + playbackState);
unregisterReceiver(myNoisyAudioStreamReceiver);
}
}
@ -89,7 +91,7 @@ public class VideoPlayerService extends Service {
@Override
public void onDestroy() {
Log.v("VideoPlayerService", "onDestroy...");
Log.v(TAG, "onDestroy...");
playerNotificationManager.setPlayer(null);
player.release();
@ -106,7 +108,7 @@ public class VideoPlayerService extends Service {
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
Log.v("VideoPlayerService", "onStartCommand...");
Log.v(TAG, "onStartCommand...");
playVideo();
return START_STICKY;
}
@ -114,27 +116,27 @@ public class VideoPlayerService extends Service {
public void setCurrentVideo(Video video)
{
Log.v("VideoPlayerService", "setCurrentVideo...");
Log.v(TAG, "setCurrentVideo...");
currentVideo = video;
}
public void setCurrentStreamUrl(String streamUrl)
{
Log.v("VideoPlayerService", "setCurrentStreamUrl...");
Log.v(TAG, "setCurrentStreamUrl...");
currentStreamUrl = streamUrl;
}
//Playback speed control
public void setPlayBackSpeed(float speed) {
Log.v("VideoPlayerService", "setPlayBackSpeed...");
Log.v(TAG, "setPlayBackSpeed...");
player.setPlaybackParameters(new PlaybackParameters(speed));
}
public void playVideo() {
Context context = this;
Log.v("VideoPlayerService", "playVideo...");
Log.v(TAG, "playVideo...");
// Produces DataSource instances through which media data is loaded.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
@ -203,7 +205,7 @@ public class VideoPlayerService extends Service {
@Override
public void onNotificationCancelled(int notificationId) {
Log.v("VideoPlayerService", "onNotificationCancelled...");
Log.v(TAG, "onNotificationCancelled...");
// TODO: only kill the notification if we no longer have a bound activity
stopForeground(true);

View File

@ -6,60 +6,122 @@
android:background="@color/videoBackgroundColor"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/video_speed05"
android:layout_width="wrap_content"
android:id="@+id/video_speed05_icon"
android:layout_width="32dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:gravity="center|start"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp"
android:textSize="12sp" />
<TextView
android:id="@+id/video_speed05"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:gravity="center|start"
android:text="@string/video_speed_05"
android:textAllCaps="false"
/>
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/video_speed10_icon"
android:layout_width="32dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:gravity="center|start"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="12sp" />
<TextView
android:id="@+id/video_speed10"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:gravity="center|start"
android:text="@string/video_speed_10"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/video_speed15_icon"
android:layout_width="32dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="16sp"
android:gravity="center|start"
android:textAllCaps="false"
android:text="@string/video_speed_10"
/>
android:textColor="#ffffff"
android:textSize="12sp" />
<TextView
android:id="@+id/video_speed15"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:gravity="center|start"
android:text="@string/video_speed_15"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/video_speed20_icon"
android:layout_width="32dp"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:gravity="center|start"
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp"
android:text="@string/video_speed_15"
android:textAllCaps="false" />
android:textSize="12sp" />
<TextView
android:id="@+id/video_speed20"
android:layout_width="wrap_content"
android:layout_width="match_parent"
android:layout_height="56dp"
android:layout_marginStart="16dp"
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:gravity="center"
android:textColor="#ffffff"
android:textSize="16sp"
android:gravity="center|start"
android:text="@string/video_speed_20"
android:textAllCaps="false" />
android:textAllCaps="false"
android:textColor="#ffffff"
android:textSize="16sp" />
</LinearLayout>
</LinearLayout>

View File

@ -89,4 +89,7 @@
<string name="video_speed_15">1.5x</string>
<string name="video_speed_20">2x</string>
<string name="video_speed_active_icon">{faw-check}</string>
</resources>