add rudimentary headlines video player
This commit is contained in:
parent
2593a8faa2
commit
5df93fe9d6
@ -8,6 +8,7 @@ import android.content.res.Resources.Theme;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Paint;
|
import android.graphics.Paint;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
|
import android.media.MediaPlayer;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@ -28,6 +29,7 @@ import android.view.ContextMenu.ContextMenuInfo;
|
|||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -43,6 +45,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.ListView;
|
import android.widget.ListView;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
import android.widget.VideoView;
|
||||||
|
|
||||||
import com.amulyakhare.textdrawable.TextDrawable;
|
import com.amulyakhare.textdrawable.TextDrawable;
|
||||||
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
import com.amulyakhare.textdrawable.util.ColorGenerator;
|
||||||
@ -654,6 +657,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
public ImageView publishedView;
|
public ImageView publishedView;
|
||||||
public TextView excerptView;
|
public TextView excerptView;
|
||||||
public ImageView flavorImageView;
|
public ImageView flavorImageView;
|
||||||
|
public VideoView flavorVideoView;
|
||||||
public TextView authorView;
|
public TextView authorView;
|
||||||
public TextView dateView;
|
public TextView dateView;
|
||||||
public CheckBox selectionBoxView;
|
public CheckBox selectionBoxView;
|
||||||
@ -820,6 +824,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
holder.publishedView = (ImageView)v.findViewById(R.id.published);
|
holder.publishedView = (ImageView)v.findViewById(R.id.published);
|
||||||
holder.excerptView = (TextView)v.findViewById(R.id.excerpt);
|
holder.excerptView = (TextView)v.findViewById(R.id.excerpt);
|
||||||
holder.flavorImageView = (ImageView) v.findViewById(R.id.flavor_image);
|
holder.flavorImageView = (ImageView) v.findViewById(R.id.flavor_image);
|
||||||
|
holder.flavorVideoView = (VideoView) v.findViewById(R.id.flavor_video);
|
||||||
holder.authorView = (TextView)v.findViewById(R.id.author);
|
holder.authorView = (TextView)v.findViewById(R.id.author);
|
||||||
holder.dateView = (TextView) v.findViewById(R.id.date);
|
holder.dateView = (TextView) v.findViewById(R.id.date);
|
||||||
holder.selectionBoxView = (CheckBox) v.findViewById(R.id.selected);
|
holder.selectionBoxView = (CheckBox) v.findViewById(R.id.selected);
|
||||||
@ -1018,9 +1023,76 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!m_compactLayoutMode) {
|
if (!m_compactLayoutMode && holder.flavorImageHolder != null) {
|
||||||
|
|
||||||
if (showFlavorImage && holder.flavorImageView != null) {
|
/* reset to default in case of convertview */
|
||||||
|
holder.flavorImageHolder.setVisibility(View.VISIBLE);
|
||||||
|
holder.flavorImageView.setVisibility(View.VISIBLE);
|
||||||
|
holder.flavorImageLoadingBar.setVisibility(View.VISIBLE);
|
||||||
|
holder.flavorVideoView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
boolean videoFound = false;
|
||||||
|
|
||||||
|
if (m_prefs.getBoolean("enable_headlines_video", false) && article.articleDoc != null && holder.flavorVideoView != null) {
|
||||||
|
Element source = article.articleDoc.select("video > source").first();
|
||||||
|
|
||||||
|
if (source != null) {
|
||||||
|
try {
|
||||||
|
Uri streamUri = Uri.parse(source.attr("src"));
|
||||||
|
|
||||||
|
if (streamUri != null) {
|
||||||
|
videoFound = true;
|
||||||
|
|
||||||
|
holder.flavorImageLoadingBar.setVisibility(View.GONE);
|
||||||
|
holder.flavorVideoView.setVisibility(View.VISIBLE);
|
||||||
|
holder.flavorImageView.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if (!streamUri.equals(holder.flavorVideoView.getTag())) {
|
||||||
|
holder.flavorVideoView.setTag(streamUri);
|
||||||
|
|
||||||
|
holder.flavorVideoView.setVideoURI(streamUri);
|
||||||
|
|
||||||
|
holder.flavorVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
|
||||||
|
@Override
|
||||||
|
public void onPrepared(MediaPlayer mp) {
|
||||||
|
//mp.setLooping(true);
|
||||||
|
mp.seekTo(1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
holder.flavorVideoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
|
||||||
|
@Override
|
||||||
|
public void onCompletion(MediaPlayer mp) {
|
||||||
|
mp.seekTo(0);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
holder.flavorVideoView.setOnTouchListener(new View.OnTouchListener() {
|
||||||
|
@Override
|
||||||
|
public boolean onTouch(View v, MotionEvent event) {
|
||||||
|
VideoView video = (VideoView) v;
|
||||||
|
|
||||||
|
if (event.getAction() == MotionEvent.ACTION_DOWN) {
|
||||||
|
if (video.isPlaying()) {
|
||||||
|
video.pause();
|
||||||
|
} else {
|
||||||
|
video.start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
videoFound = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!videoFound && showFlavorImage && holder.flavorImageView != null) {
|
||||||
holder.flavorImageArrow.setVisibility(View.GONE);
|
holder.flavorImageArrow.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (article.noValidFlavorImage) {
|
if (article.noValidFlavorImage) {
|
||||||
@ -1119,7 +1191,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener,
|
|||||||
holder.flavorImageHolder.setVisibility(View.GONE);
|
holder.flavorImageHolder.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (holder.flavorImageHolder != null) {
|
} else if (!videoFound && holder.flavorImageHolder != null) {
|
||||||
holder.flavorImageHolder.setVisibility(View.GONE);
|
holder.flavorImageHolder.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,13 @@
|
|||||||
android:cropToPadding="true"
|
android:cropToPadding="true"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
|
<VideoView
|
||||||
|
android:id="@+id/flavor_video"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<org.fox.ttrss.util.ArrowRight
|
<org.fox.ttrss.util.ArrowRight
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:id="@+id/flavorImageArrow"
|
android:id="@+id/flavorImageArrow"
|
||||||
|
@ -93,6 +93,13 @@
|
|||||||
android:cropToPadding="true"
|
android:cropToPadding="true"
|
||||||
android:visibility="visible" />
|
android:visibility="visible" />
|
||||||
|
|
||||||
|
<VideoView
|
||||||
|
android:id="@+id/flavor_video"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
<org.fox.ttrss.util.ArrowRight
|
<org.fox.ttrss.util.ArrowRight
|
||||||
android:layout_marginRight="16dp"
|
android:layout_marginRight="16dp"
|
||||||
android:id="@+id/flavorImageArrow"
|
android:id="@+id/flavorImageArrow"
|
||||||
|
@ -188,6 +188,12 @@
|
|||||||
android:defaultValue="false"
|
android:defaultValue="false"
|
||||||
android:key="transport_debugging"
|
android:key="transport_debugging"
|
||||||
android:title="@string/transport_debugging" />
|
android:title="@string/transport_debugging" />
|
||||||
|
<org.fox.ttrss.util.LessBrokenSwitchPreference
|
||||||
|
android:defaultValue="false"
|
||||||
|
android:key="enable_headlines_video"
|
||||||
|
android:title="Video in headlines"
|
||||||
|
android:summary="Enable rudimentary video player in headlines view" />
|
||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
<Preference
|
<Preference
|
||||||
|
Loading…
x
Reference in New Issue
Block a user