All players in one place

- main, background, popup players now connected via one service, one view, one fragment, one activity and one gesture listener
- playback position is synchronized between players. Easy to switch from one to another
- expandable player at the bottom of the screen with cool animation and additional features like long click to open channel of a video, play/pause/close buttons and swipe down to dismiss
- in-player integrated buttons for opening in browser, playing with Kodi, sharing a video
- better background playback that can be activated in settings. Allows to automatically switch to audio-only mode when going to background and then switching to video-mode when returning to the app.
This commit is contained in:
Avently 2019-12-30 00:15:01 +03:00
parent 9904e14904
commit efc10c8717
29 changed files with 4057 additions and 531 deletions

View file

@ -5,13 +5,44 @@
android:id="@+id/video_item_detail"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/windowBackground"
android:focusableInTouchMode="true">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:id="@+id/detail_main_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fitsSystemWindows="true">
android:layout_height="wrap_content">
<!--
You may wonder why this NestedScrollView locates on top of the file. That's because BottomSheetBehavior
can work well only with one element that implements nested scrolling. But we have two:
one NestedScrollView for ViewPager with id = viewpager here
second ViewPager with id = playQueue inside activity_main_player.xml.
By placing this NestedScrollView on top of the file we are getting this ViewPager working -->
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:fillViewport="true">
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="bottom|center"
app:tabBackground="@drawable/tab_selector"
app:tabGravity="center"
app:tabIndicatorHeight="0dp"/>
</androidx.viewpager.widget.ViewPager>
</androidx.core.widget.NestedScrollView>
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/appbarlayout"
@ -140,6 +171,13 @@
tools:progress="40"
tools:visibility="visible" />
<!-- Player will be inserted here in realtime -->
<FrameLayout
android:id="@+id/player_placeholder"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
</FrameLayout>
</com.google.android.material.appbar.CollapsingToolbarLayout>
@ -149,7 +187,6 @@
android:id="@+id/detail_content_root_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?android:windowBackground"
app:layout_scrollFlags="scroll">
<!-- TITLE -->
@ -504,25 +541,106 @@
</com.google.android.material.appbar.AppBarLayout>
<androidx.viewpager.widget.ViewPager
android:id="@+id/viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
<com.google.android.material.tabs.TabLayout
android:id="@+id/tablayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center"
android:background="@color/transparent_background_color"
app:tabBackground="@drawable/tab_selector"
app:tabGravity="center"
app:tabIndicatorHeight="0dp">
</com.google.android.material.tabs.TabLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<RelativeLayout
android:id="@+id/overlay_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0"
tools:alpha="1"
android:paddingLeft="@dimen/video_item_search_padding"
android:paddingRight="@dimen/video_item_search_padding"
android:background="?attr/windowBackground" >
<ImageButton
android:id="@+id/overlay_thumbnail"
android:layout_width="50dp"
android:layout_height="60dp"
android:layout_alignParentStart="true"
android:scaleType="fitCenter"
android:gravity="center_vertical"
android:contentDescription="@string/list_thumbnail_view_description"
android:src="@drawable/dummy_thumbnail"
android:background="@color/transparent_background_color"/>
<LinearLayout
android:id="@+id/overlay_metadata_layout"
android:layout_width="match_parent"
android:layout_height="60dp"
android:gravity="center_vertical"
android:orientation="vertical"
android:paddingLeft="@dimen/video_item_search_padding"
android:paddingRight="@dimen/video_item_search_padding"
android:clickable="true"
android:focusable="true"
android:layout_toEndOf="@+id/overlay_thumbnail"
android:layout_toStartOf="@+id/overlay_buttons_layout"
tools:ignore="RtlHardcoded">
<TextView
android:id="@+id/overlay_title_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="@dimen/video_item_search_title_text_size"
tools:ignore="RtlHardcoded"
tools:text="The Video Title LONG very LONVideo Title LONG very LONG"/>
<TextView
android:id="@+id/overlay_channel_text_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:fadingEdge="horizontal"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="?android:attr/textAppearanceSmall"
android:textSize="@dimen/video_item_search_uploader_text_size"
tools:text="The Video Artist LONG very LONG very Long"/>
</LinearLayout>
<LinearLayout
android:id="@+id/overlay_buttons_layout"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:gravity="center_vertical"
android:paddingLeft="@dimen/video_item_search_padding"
android:layout_alignParentEnd="true"
tools:ignore="RtlHardcoded">
<ImageButton
android:id="@+id/overlay_play_pause_button"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginLeft="2dp"
android:layout_marginRight="2dp"
android:padding="10dp"
android:scaleType="center"
android:src="@drawable/ic_pause_white_24dp"
android:background="?attr/selectableItemBackground"
tools:ignore="ContentDescription,RtlHardcoded"/>
<ImageButton
android:id="@+id/overlay_close_button"
android:layout_width="36dp"
android:layout_height="36dp"
android:layout_marginLeft="2dp"
android:padding="10dp"
android:scaleType="center"
android:src="?attr/close"
android:background="?attr/selectableItemBackground"
tools:ignore="ContentDescription,RtlHardcoded"/>
</LinearLayout>
</RelativeLayout>
</FrameLayout>