about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2026-02-13 21:34:36 +0300
committerAndrew Dolgov <fox@fakecake.org>2026-02-13 21:34:36 +0300
commit03b3998200212093b4f5f2a8c2bb433c83dc5381 (patch)
tree9619321f519c2013362327f909d61b88df7ec119
parentdeee6a47af8ebbf82a008af06cdd3dabc7cc90a1 (diff)
downloadtt-rss-android-03b3998200212093b4f5f2a8c2bb433c83dc5381.tar.gz
tt-rss-android-03b3998200212093b4f5f2a8c2bb433c83dc5381.tar.xz
add wip implementation for headlines inline video player based on media3 exoplayer
-rwxr-xr-xorg.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java86
-rwxr-xr-xorg.fox.ttrss/src/main/res/layout/headlines_row.xml2
-rwxr-xr-xorg.fox.ttrss/src/main/res/xml/preferences.xml1
3 files changed, 60 insertions, 29 deletions
diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
index 0b291e4a..2c081474 100755
--- a/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
+++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java
@@ -29,7 +29,6 @@ import android.view.Display;
 import android.view.LayoutInflater;
 import android.view.MenuInflater;
 import android.view.MenuItem;
-import android.view.TextureView;
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.WindowManager;
@@ -48,6 +47,12 @@ import androidx.annotation.Nullable;
 import androidx.core.content.ContextCompat;
 import androidx.core.view.ViewCompat;
 import androidx.lifecycle.ViewModelProvider;
+import androidx.media3.common.MediaItem;
+import androidx.media3.common.PlaybackException;
+import androidx.media3.common.Player;
+import androidx.media3.common.util.UnstableApi;
+import androidx.media3.exoplayer.ExoPlayer;
+import androidx.media3.ui.PlayerView;
 import androidx.preference.PreferenceManager;
 import androidx.recyclerview.widget.DefaultItemAnimator;
 import androidx.recyclerview.widget.ItemTouchHelper;
@@ -118,7 +123,6 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
     private HeadlinesFragmentModel m_headlinesFragmentModel;
 
     private MediaPlayer m_mediaPlayer;
-    private TextureView m_activeTexture;
 
     public void initialize(Feed feed) {
         m_feed = feed;
@@ -579,7 +583,7 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
         public ImageView textChecked;
         public View headlineHeader;
         public View flavorImageOverflow;
-        public TextureView flavorVideoView;
+        public PlayerView flavorVideoView;
         public MaterialButton attachmentsView;
         public TextView linkHost;
 
@@ -1122,10 +1126,58 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
                     }
                 }
 
-				/* if (m_prefs.getBoolean("inline_video_player", false) && article.flavorImage != null &&
+				if (m_prefs.getBoolean("inline_video_player", false) && article.flavorImage != null &&
 						"video".equalsIgnoreCase(article.flavorImage.tagName()) && article.flavorStreamUri != null) {
 
-					holder.flavorVideoView.setOnLongClickListener(v -> {
+                    Log.d(TAG, "inline exoplayer init for " + article.flavorStreamUri);
+
+                    PlayerView playerView = holder.flavorVideoView;
+
+                    ExoPlayer player = new ExoPlayer.Builder(getContext()).build();
+
+                    playerView.setPlayer(player);
+                    playerView.setOnLongClickListener(new View.OnLongClickListener() {
+                        @Override
+                        public boolean onLongClick(View view) {
+                            openGalleryForType(article, holder, holder.flavorImageView);
+                            return true;
+                        }
+                    });
+
+                    player.setMediaItem(MediaItem.fromUri(article.flavorStreamUri));
+                    player.prepare();
+                    player.setPlayWhenReady(false);
+                    player.setRepeatMode(Player.REPEAT_MODE_ONE);
+
+                    holder.flavorVideoView.setVisibility(View.VISIBLE);
+
+                    final ProgressBar bar = holder.flavorImageLoadingBar;
+
+                    bar.setIndeterminate(true);
+                    bar.setVisibility(View.VISIBLE);
+
+                    player.addListener(new Player.Listener() {
+                        @Override
+                        public void onPlayerError(PlaybackException error) {
+                            Log.d(TAG, "onPlayerError:" + error);
+
+                            m_activity.toast(error.getMessage());
+                        }
+
+                        @UnstableApi
+                        @Override
+                        public void onIsLoadingChanged(boolean isLoading) {
+                            Log.d(TAG, "onIsLoadingChanged" + isLoading);
+
+                            bar.setVisibility(isLoading ? View.VISIBLE : View.GONE);
+
+                            holder.flavorImageView.setVisibility(View.INVISIBLE);
+
+                            playerView.hideController();
+                        }
+                    });
+
+					/* holder.flavorVideoView.setOnLongClickListener(v -> {
                         releaseSurface();
                         openGalleryForType(article, holder, holder.flavorImageView);
                         return true;
@@ -1215,11 +1267,11 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
                              }
                         );
 
-                    });
+                    }); */
 
 				} else {
 					holder.flavorImageView.setOnClickListener(view -> openGalleryForType(article, holder, holder.flavorImageView));
-				} */
+				}
             }
         }
 
@@ -1557,24 +1609,6 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
         }
     }
 
-    private void releaseSurface() {
-        try {
-            if (m_mediaPlayer != null) {
-                m_mediaPlayer.release();
-            }
-        } catch (IllegalStateException e) {
-            e.printStackTrace();
-        }
-
-        try {
-            if (m_activeTexture != null) {
-                m_activeTexture.setVisibility(View.GONE);
-            }
-        } catch (IllegalStateException e) {
-            e.printStackTrace();
-        }
-    }
-
     public void scrollToArticle(Article article) {
         int position = Application.getArticles().indexOf(article);
 
@@ -1590,8 +1624,6 @@ public class HeadlinesFragment extends androidx.fragment.app.Fragment {
     @Override
     public void onPause() {
         super.onPause();
-
-        releaseSurface();
     }
 
     private void syncToSharedArticles() {
diff --git a/org.fox.ttrss/src/main/res/layout/headlines_row.xml b/org.fox.ttrss/src/main/res/layout/headlines_row.xml
index 943e7073..562e3e97 100755
--- a/org.fox.ttrss/src/main/res/layout/headlines_row.xml
+++ b/org.fox.ttrss/src/main/res/layout/headlines_row.xml
@@ -129,7 +129,7 @@
                     tools:src="@drawable/ic_launcher_background"
                     android:visibility="visible" />
 
-                <TextureView
+                <androidx.media3.ui.PlayerView
                     android:id="@+id/flavor_video"
                     android:layout_width="match_parent"
                     android:layout_height="wrap_content"
diff --git a/org.fox.ttrss/src/main/res/xml/preferences.xml b/org.fox.ttrss/src/main/res/xml/preferences.xml
index fe9f1477..9688a3c3 100755
--- a/org.fox.ttrss/src/main/res/xml/preferences.xml
+++ b/org.fox.ttrss/src/main/res/xml/preferences.xml
@@ -160,7 +160,6 @@
             android:summary="@string/prefs_always_downsample_images_long" />
 
         <SwitchPreferenceCompat
-            android:enabled="false"
             android:defaultValue="false"
             android:key="inline_video_player"
             android:summary="@string/prefs_inline_video_player"