diff options
Diffstat (limited to 'org.fox.ttrss/src/main/java/org')
-rwxr-xr-x | org.fox.ttrss/src/main/java/org/fox/ttrss/HeadlinesFragment.java | 77 | ||||
-rw-r--r-- | org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java | 146 |
2 files changed, 159 insertions, 64 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 1fcdd721..45fb5480 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 @@ -1037,7 +1037,7 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, try { Element source = video.select("source").first(); - String streamUri = source.attr("src"); + final String streamUri = source.attr("src"); String posterUri = video.attr("poster"); if (streamUri != null && posterUri != null) { @@ -1056,11 +1056,22 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, holder.flavorImageView.setVisibility(View.VISIBLE); holder.flavorVideoPlayView.setVisibility(View.VISIBLE); + ViewCompat.setTransitionName(holder.flavorImageView, "TRANSITION:ARTICLE_VIDEO_PLAYER"); + holder.flavorImageView.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { - // + Intent intent = new Intent(m_activity, VideoPlayerActivity.class); + intent.putExtra("streamUri", streamUri); + intent.putExtra("title", article.title); + + ActivityOptionsCompat options = + ActivityOptionsCompat.makeSceneTransitionAnimation(m_activity, + holder.flavorImageView, // The view which starts the transition + "TRANSITION:ARTICLE_VIDEO_PLAYER" // The transitionName of the view we’re transitioning to + ); + ActivityCompat.startActivity(m_activity, intent, options.toBundle()); } }); @@ -1075,68 +1086,6 @@ public class HeadlinesFragment extends Fragment implements OnItemClickListener, } - /* 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); - holder.flavorVideoPlayView.setVisibility(View.VISIBLE); - - 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(); - holder.flavorVideoPlayView.setVisibility(View.VISIBLE); - } else { - video.start(); - holder.flavorVideoPlayView.setVisibility(View.GONE); - } - } - - return true; - } - }); - } - } - } catch (Exception e) { - e.printStackTrace(); - videoFound = false; - } - } - } */ - if (!videoFound && showFlavorImage && holder.flavorImageView != null) { holder.flavorImageArrow.setVisibility(View.GONE); diff --git a/org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java b/org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java new file mode 100644 index 00000000..81aa09cc --- /dev/null +++ b/org.fox.ttrss/src/main/java/org/fox/ttrss/VideoPlayerActivity.java @@ -0,0 +1,146 @@ +package org.fox.ttrss;
+
+import android.content.Intent;
+import android.content.res.Configuration;
+import android.media.MediaPlayer;
+import android.net.Uri;
+import android.os.Bundle;
+import android.support.v7.widget.Toolbar;
+import android.util.Log;
+import android.view.ContextMenu;
+import android.view.Menu;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.MediaController;
+import android.widget.VideoView;
+
+
+public class VideoPlayerActivity extends CommonActivity {
+
+ private final String TAG = this.getClass().getSimpleName();
+ private String m_streamUri;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+
+ setTheme(R.style.DarkTheme);
+
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_video_player);
+
+ Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
+ setSupportActionBar(toolbar);
+
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+
+ if (!isPortrait())
+ getSupportActionBar().hide();
+
+ VideoView videoView = (VideoView) findViewById(R.id.video_player);
+ registerForContextMenu(videoView); // doesn't work :[
+
+ setTitle(getIntent().getStringExtra("title"));
+
+ if (savedInstanceState == null) {
+ m_streamUri = getIntent().getStringExtra("streamUri");
+ } else {
+ m_streamUri = savedInstanceState.getString("streamUri");
+ }
+
+ final MediaController mediaController = new MediaController(this);
+ mediaController.setAnchorView(videoView);
+ videoView.setMediaController(mediaController);
+ videoView.setVideoURI(Uri.parse(m_streamUri));
+
+ videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
+ @Override
+ public void onPrepared(MediaPlayer mp) {
+ mp.setLooping(true);
+ }
+ });
+
+ videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
+ @Override
+ public void onCompletion(MediaPlayer mp) {
+ mp.seekTo(0);
+ }
+ });
+
+ videoView.start();
+ }
+
+ public void onConfigurationChanged(Configuration newConfig) {
+ super.onConfigurationChanged(newConfig);
+
+ if (!isPortrait())
+ getSupportActionBar().hide();
+ else
+ getSupportActionBar().show();
+ }
+
+ @Override
+ public void onSaveInstanceState(Bundle out) {
+ super.onSaveInstanceState(out);
+
+ out.putString("streamUri", m_streamUri);
+ }
+
+
+ @Override
+ public boolean onCreateOptionsMenu(Menu menu) {
+ getMenuInflater().inflate(R.menu.activity_video_player, menu);
+ return true;
+ }
+
+
+ @Override
+ public void onCreateContextMenu(ContextMenu menu, View v,
+ ContextMenu.ContextMenuInfo menuInfo) {
+
+ getMenuInflater().inflate(R.menu.activity_video_player, menu);
+
+ super.onCreateContextMenu(menu, v, menuInfo);
+ }
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ return onContextItemSelected(item); // this is really bad :()
+ }
+
+ @Override
+ public boolean onContextItemSelected(android.view.MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ onBackPressed();
+ return true;
+ case R.id.article_vid_open:
+ if (m_streamUri != null) {
+ try {
+ Intent intent = new Intent(Intent.ACTION_VIEW,
+ Uri.parse(m_streamUri));
+ startActivity(intent);
+ } catch (Exception e) {
+ e.printStackTrace();
+ toast(R.string.error_other_error);
+ }
+ }
+ return true;
+ case R.id.article_vid_share:
+ if (m_streamUri != null) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+
+ intent.setType("video/mp4");
+ intent.putExtra(Intent.EXTRA_SUBJECT, m_streamUri);
+ intent.putExtra(Intent.EXTRA_TEXT, m_streamUri);
+
+ startActivity(Intent.createChooser(intent, m_streamUri));
+ }
+ return true;
+ default:
+ Log.d(TAG, "onContextItemSelected, unhandled id=" + item.getItemId());
+ return super.onContextItemSelected(item);
+ }
+ }
+
+}
|