|
|
|
|
@ -3,6 +3,8 @@ package com.fongmi.android.tv.player; |
|
|
|
|
import android.app.Activity; |
|
|
|
|
import android.app.PendingIntent; |
|
|
|
|
import android.content.Intent; |
|
|
|
|
import android.graphics.Bitmap; |
|
|
|
|
import android.graphics.drawable.BitmapDrawable; |
|
|
|
|
import android.net.Uri; |
|
|
|
|
import android.os.Bundle; |
|
|
|
|
import android.support.v4.media.MediaMetadataCompat; |
|
|
|
|
@ -136,10 +138,6 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac |
|
|
|
|
return session; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setMetadata(MediaMetadataCompat metadata) { |
|
|
|
|
session.setMetadata(metadata); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getDecode() { |
|
|
|
|
return decode; |
|
|
|
|
} |
|
|
|
|
@ -446,29 +444,52 @@ public class Players implements Player.Listener, AnalyticsListener, ParseCallbac |
|
|
|
|
return bundle; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setMetadata(String title, String artist, PlayerView view) { |
|
|
|
|
try { |
|
|
|
|
Bitmap bitmap = ((BitmapDrawable) view.getDefaultArtwork()).getBitmap(); |
|
|
|
|
MediaMetadataCompat.Builder builder = new MediaMetadataCompat.Builder(); |
|
|
|
|
builder.putString(MediaMetadataCompat.METADATA_KEY_TITLE, title); |
|
|
|
|
builder.putString(MediaMetadataCompat.METADATA_KEY_ARTIST, artist); |
|
|
|
|
builder.putBitmap(MediaMetadataCompat.METADATA_KEY_ART, bitmap); |
|
|
|
|
builder.putLong(MediaMetadataCompat.METADATA_KEY_DURATION, getDuration()); |
|
|
|
|
session.setMetadata(builder.build()); |
|
|
|
|
ActionEvent.update(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void share(Activity activity, CharSequence title) { |
|
|
|
|
if (isEmpty()) return; |
|
|
|
|
Intent intent = new Intent(Intent.ACTION_SEND); |
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
|
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, getUrl()); |
|
|
|
|
intent.putExtra("extra_headers", getHeaderBundle()); |
|
|
|
|
intent.putExtra("title", title); |
|
|
|
|
intent.putExtra("name", title); |
|
|
|
|
intent.setType("text/plain"); |
|
|
|
|
activity.startActivity(Util.getChooser(intent)); |
|
|
|
|
try { |
|
|
|
|
if (isEmpty()) return; |
|
|
|
|
Intent intent = new Intent(Intent.ACTION_SEND); |
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
|
|
|
|
intent.putExtra(Intent.EXTRA_TEXT, getUrl()); |
|
|
|
|
intent.putExtra("extra_headers", getHeaderBundle()); |
|
|
|
|
intent.putExtra("title", title); |
|
|
|
|
intent.putExtra("name", title); |
|
|
|
|
intent.setType("text/plain"); |
|
|
|
|
activity.startActivity(Util.getChooser(intent)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void choose(Activity activity, CharSequence title) { |
|
|
|
|
if (isEmpty()) return; |
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW); |
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
|
|
|
|
intent.setDataAndType(getUri(), "video/*"); |
|
|
|
|
intent.putExtra("title", title); |
|
|
|
|
intent.putExtra("return_result", isVod()); |
|
|
|
|
intent.putExtra("headers", getHeaderArray()); |
|
|
|
|
if (isVod()) intent.putExtra("position", (int) getPosition()); |
|
|
|
|
activity.startActivityForResult(Util.getChooser(intent), 1001); |
|
|
|
|
try { |
|
|
|
|
if (isEmpty()) return; |
|
|
|
|
Intent intent = new Intent(Intent.ACTION_VIEW); |
|
|
|
|
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); |
|
|
|
|
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); |
|
|
|
|
intent.setDataAndType(getUri(), "video/*"); |
|
|
|
|
intent.putExtra("title", title); |
|
|
|
|
intent.putExtra("return_result", isVod()); |
|
|
|
|
intent.putExtra("headers", getHeaderArray()); |
|
|
|
|
if (isVod()) intent.putExtra("position", (int) getPosition()); |
|
|
|
|
activity.startActivityForResult(Util.getChooser(intent), 1001); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void checkData(Intent data) { |
|
|
|
|
|