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

Add Lyrics support but not happy for merge #119

Open
wants to merge 2 commits 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
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# VLC for Android

## About this branch: Lyrics
I made the just work patch for adding lyrics function for audio.

But I'm sorry about the "dirty" code, so It will not be merged to the original repo.
But anyone need the lyrics is welcome to download the apk from the release section of this repo.

* support .lrc external lyrics
* support for remember play position for each audio is not work (why?)
* small issue like lyrics not shown when pause is pressed

Thanks

------
This is the official **Android** port of [VLC](https://videolan.org/vlc/).

VLC on Android plays all the same files as the classical version of VLC, and features a media database
Expand Down
6 changes: 4 additions & 2 deletions application/vlc-android/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,10 @@
android:name="android.hardware.bluetooth"
android:required="false"/>

<application>

<application android:requestLegacyExternalStorage="true">
<meta-data
android:name="requestLegacyExternalStorage"
android:value="true"/>
<!-- Enable VLC in Samsung multiwindow mode -->
<meta-data
android:name="com.samsung.android.sdk.multiwindow.enable"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,57 @@
~
~
-->
<LinearLayout
android:id="@+id/lyrics_lines"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:orientation="vertical"

<androidx.constraintlayout.widget.ConstraintLayout
>

<TextView
android:id="@+id/line_p2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="-2"
android:textAlignment="center"
android:textSize="16sp" />

<TextView
android:id="@+id/line_p1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="-1"
android:textAlignment="center"
android:textSize="19sp" />

<TextView
android:id="@+id/line_current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="current"
android:textAlignment="center"
android:textSize="22sp"
android:textStyle="bold" />

<TextView
android:id="@+id/line_n1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="+1"
android:textAlignment="center"
android:textSize="16sp"
android:visibility="gone" />


<androidx.constraintlayout.widget.ConstraintLayout android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
android:background="#00000000"
android:orientation="horizontal">

Expand Down Expand Up @@ -120,4 +167,5 @@


</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</layout>
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,58 @@
~
~
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/lyrics_lines"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:orientation="vertical"

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
>

<TextView
android:id="@+id/line_p2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="-2"
android:textAlignment="center"
android:textSize="16sp" />

<TextView
android:id="@+id/line_p1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="-1"
android:textAlignment="center"
android:textSize="19sp" />

<TextView
android:id="@+id/line_current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="current"
android:textAlignment="center"
android:textSize="22sp"
android:textStyle="bold" />

<TextView
android:id="@+id/line_n1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="+1"
android:textAlignment="center"
android:textSize="16sp"
android:visibility="gone" />

<androidx.constraintlayout.widget.ConstraintLayout android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="0dp"
android:clipToPadding="false"
android:background="#00000000"
android:orientation="horizontal">
Expand Down Expand Up @@ -102,4 +148,6 @@
app:layout_goneMarginBottom="32dp"
tools:text="Beethoven" />


</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
97 changes: 72 additions & 25 deletions application/vlc-android/res/layout/cover_media_switcher_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,79 @@
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<!--
~ *************************************************************************
~ cover_media_switcher_item.xml
~ **************************************************************************
~ Copyright © 2021 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->
<LinearLayout
android:id="@+id/lyrics_lines"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="40dp"
android:orientation="vertical"
>

<androidx.constraintlayout.widget.ConstraintLayout
<TextView
android:id="@+id/line_p2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="-2"
android:textAlignment="center"
android:textSize="16sp" />

<TextView
android:id="@+id/line_p1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="-1"
android:textAlignment="center"
android:textSize="19sp" />

<TextView
android:id="@+id/line_current"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="current"
android:textAlignment="center"
android:textSize="22sp"
android:textStyle="bold" />

<TextView
android:id="@+id/line_n1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="serif"
android:text="+1"
android:textAlignment="center"
android:textSize="16sp"
android:visibility="gone" />

<!--
~ *************************************************************************
~ cover_media_switcher_item.xml
~ **************************************************************************
~ Copyright © 2021 VLC authors and VideoLAN
~ Author: Nicolas POMEPUY
~ This program is free software; you can redistribute it and/or modify
~ it under the terms of the GNU General Public License as published by
~ the Free Software Foundation; either version 2 of the License, or
~ (at your option) any later version.
~
~ This program is distributed in the hope that it will be useful,
~ but WITHOUT ANY WARRANTY; without even the implied warranty of
~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
~ GNU General Public License for more details.
~
~ You should have received a copy of the GNU General Public License
~ along with this program; if not, write to the Free Software
~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
~ ***************************************************************************
~
~
-->

<androidx.constraintlayout.widget.ConstraintLayout android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_height="0dp"
android:background="#00000000"
android:orientation="horizontal">

Expand Down Expand Up @@ -121,4 +167,5 @@
tools:text="Bitrate: 22.4 KB/s - Codec: Vorbis audio - Sample rate 8000 Hz" />

</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
</layout>
3 changes: 3 additions & 0 deletions application/vlc-android/src/debug/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,7 @@
<uses-permission
android:name="android.permission.DUMP"
tools:ignore="ProtectedPermissions" />
<application android:requestLegacyExternalStorage="true">

</application>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ import org.videolan.resources.util.registerReceiverCompat
import org.videolan.resources.util.startForegroundCompat
import org.videolan.tools.*
import org.videolan.vlc.car.VLCCarService
import org.videolan.vlc.gui.audio.Lyrics
import org.videolan.vlc.gui.dialogs.VideoTracksDialog
import org.videolan.vlc.gui.dialogs.adapters.VlcTrack
import org.videolan.vlc.gui.helpers.AudioUtil
Expand Down Expand Up @@ -1597,6 +1598,7 @@ class PlaybackService : MediaBrowserServiceCompat(), LifecycleOwner, CoroutineSc
setPosition((time.toFloat() / NO_LENGTH_PROGRESS_MAX.toFloat()))
if (fromUser) publishState(time)
}
Lyrics.seek(time);
// Required to update timeline when paused
if (fromUser && isPaused) showNotification()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
}

setBottomMargin()
Lyrics.setUI(binding);
}

override fun onDestroy() {
Expand Down Expand Up @@ -476,6 +477,7 @@ class AudioPlayer : Fragment(), PlaylistAdapter.IPlayer, TextWatcher, IAudioPlay
binding.time.text = displayTime
if (!isDragging) binding.timeline.progress = progress.time.toInt()
binding.progressBar.progress = progress.time.toInt()
Lyrics.progress(progress.time);
}

lifecycleScope.launchWhenStarted {
Expand Down
Loading