本文整理汇总了Java中org.telegram.tgnet.TLRPC.TL_documentAttributeAudio方法的典型用法代码示例。如果您正苦于以下问题:Java TLRPC.TL_documentAttributeAudio方法的具体用法?Java TLRPC.TL_documentAttributeAudio怎么用?Java TLRPC.TL_documentAttributeAudio使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.telegram.tgnet.TLRPC
的用法示例。
在下文中一共展示了TLRPC.TL_documentAttributeAudio方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMusicTitle
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public String getMusicTitle() {
TLRPC.Document document;
if (type == 0) {
document = messageOwner.media.webpage.document;
} else {
document = messageOwner.media.document;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.voice) {
return LocaleController.formatDateAudio(messageOwner.date);
}
String title = attribute.title;
if (title == null || title.length() == 0) {
title = FileLoader.getDocumentFileName(document);
if (title == null || title.length() == 0) {
title = LocaleController.getString("AudioUnknownTitle", R.string.AudioUnknownTitle);
}
}
return title;
}
}
return "";
}
示例2: updateWaveform
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
private void updateWaveform() {
if (currentMessageObject == null || documentAttachType != DOCUMENT_ATTACH_TYPE_AUDIO) {
return;
}
for (int a = 0; a < documentAttach.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = documentAttach.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.waveform == null || attribute.waveform.length == 0) {
MediaController.getInstance().generateWaveform(currentMessageObject);
}
useSeekBarWaweform = attribute.waveform != null;
seekBarWaveform.setWaveform(attribute.waveform);
break;
}
}
}
示例3: isVoiceDocument
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public static boolean isVoiceDocument(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return attribute.voice;
}
}
}
return false;
}
示例4: isMusicDocument
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public static boolean isMusicDocument(TLRPC.Document document) {
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return !attribute.voice;
}
}
}
return false;
}
示例5: getDuration
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public int getDuration() {
TLRPC.Document document;
if (type == 0) {
document = messageOwner.media.webpage.document;
} else {
document = messageOwner.media.document;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
return attribute.duration;
}
}
return 0;
}
示例6: getMusicAuthor
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public String getMusicAuthor() {
TLRPC.Document document;
if (type == 0) {
document = messageOwner.media.webpage.document;
} else {
document = messageOwner.media.document;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.voice) {
if (isOutOwner() || messageOwner.fwd_from != null && messageOwner.fwd_from.from_id == UserConfig.getClientUserId()) {
return LocaleController.getString("FromYou", R.string.FromYou);
}
TLRPC.User user = null;
TLRPC.Chat chat = null;
if (messageOwner.fwd_from != null && messageOwner.fwd_from.channel_id != 0) {
chat = MessagesController.getInstance().getChat(messageOwner.fwd_from.channel_id);
} else if (messageOwner.fwd_from != null && messageOwner.fwd_from.from_id != 0) {
user = MessagesController.getInstance().getUser(messageOwner.fwd_from.from_id);
} else if (messageOwner.from_id < 0) {
chat = MessagesController.getInstance().getChat(-messageOwner.from_id);
} else {
user = MessagesController.getInstance().getUser(messageOwner.from_id);
}
if (user != null) {
return UserObject.getUserName(user);
} else if (chat != null) {
return chat.title;
}
}
String performer = attribute.performer;
if (performer == null || performer.length() == 0) {
performer = LocaleController.getString("AudioUnknownArtist", R.string.AudioUnknownArtist);
}
return performer;
}
}
return "";
}
示例7: updateProgress
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void updateProgress() {
if (currentMessageObject == null) {
return;
}
if (!seekBar.isDragging()) {
seekBar.setProgress(currentMessageObject.audioProgress);
}
int duration = 0;
if (!MediaController.getInstance().isPlayingAudio(currentMessageObject)) {
for (int a = 0; a < currentMessageObject.getDocument().attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = currentMessageObject.getDocument().attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
duration = attribute.duration;
break;
}
}
} else {
duration = currentMessageObject.audioProgressSec;
}
String timeString = String.format("%02d:%02d", duration / 60, duration % 60);
if (lastTimeString == null || lastTimeString != null && !lastTimeString.equals(timeString)) {
timeWidth = (int)Math.ceil(timePaint.measureText(timeString));
timeLayout = new StaticLayout(timeString, timePaint, timeWidth, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false);
}
invalidate();
}
示例8: updateTitle
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
private void updateTitle(boolean shutdown) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) {
if (parentLayout != null && !parentLayout.fragmentsStack.isEmpty() && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1) == this) {
finishFragment();
} else {
removeSelfFromStack();
}
} else {
if (messageObject == null) {
return;
}
checkIfMusicDownloaded(messageObject);
updateProgress(messageObject);
if (MediaController.getInstance().isAudioPaused()) {
playButton.setImageResource(R.drawable.player_play_states);
} else {
playButton.setImageResource(R.drawable.player_pause_states);
}
if (actionBar != null) {
actionBar.setTitle(messageObject.getMusicTitle());
actionBar.getTitleTextView().setTextColor(0xff212121);
actionBar.setSubtitle(messageObject.getMusicAuthor());
actionBar.getSubtitleTextView().setTextColor(0xff8a8a8a);
}
AudioInfo audioInfo = MediaController.getInstance().getAudioInfo();
if (audioInfo != null && audioInfo.getCover() != null) {
placeholder.setImageBitmap(audioInfo.getCover());
placeholder.setPadding(0, 0, 0, 0);
placeholder.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
placeholder.setImageResource(R.drawable.nocover);
placeholder.setPadding(0, 0, 0, AndroidUtilities.dp(30));
placeholder.setScaleType(ImageView.ScaleType.CENTER);
}
if (durationTextView != null) {
int duration = 0;
TLRPC.Document document = messageObject.getDocument();
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
duration = attribute.duration;
break;
}
}
}
durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--");
}
}
}
示例9: setDocument
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
public void setDocument(MessageObject messageObject, boolean divider) {
needDivider = divider;
message = messageObject;
loaded = false;
loading = false;
if (messageObject != null && messageObject.getDocument() != null) {
int idx;
String name = null;
if (messageObject.isMusic()) {
TLRPC.Document document;
if (messageObject.type == 0) {
document = messageObject.messageOwner.media.webpage.document;
} else {
document = messageObject.messageOwner.media.document;
}
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
if (attribute.performer != null && attribute.performer.length() != 0 || attribute.title != null && attribute.title.length() != 0) {
name = messageObject.getMusicAuthor() + " - " + messageObject.getMusicTitle();
}
}
}
}
String fileName = FileLoader.getDocumentFileName(messageObject.getDocument());
if (name == null) {
name = fileName;
}
nameTextView.setText(name);
placeholderImabeView.setVisibility(VISIBLE);
extTextView.setVisibility(VISIBLE);
placeholderImabeView.setImageResource(getThumbForNameOrMime(fileName, messageObject.getDocument().mime_type));
extTextView.setText((idx = fileName.lastIndexOf('.')) == -1 ? "" : fileName.substring(idx + 1).toLowerCase());
if (messageObject.getDocument().thumb instanceof TLRPC.TL_photoSizeEmpty || messageObject.getDocument().thumb == null) {
thumbImageView.setVisibility(INVISIBLE);
thumbImageView.setImageBitmap(null);
} else {
thumbImageView.setVisibility(VISIBLE);
thumbImageView.setImage(messageObject.getDocument().thumb.location, "40_40", (Drawable) null);
}
long date = (long) messageObject.messageOwner.date * 1000;
dateTextView.setText(String.format("%s, %s", AndroidUtilities.formatFileSize(messageObject.getDocument().size), LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, LocaleController.getInstance().formatterYear.format(new Date(date)), LocaleController.getInstance().formatterDay.format(new Date(date)))));
} else {
nameTextView.setText("");
extTextView.setText("");
dateTextView.setText("");
placeholderImabeView.setVisibility(VISIBLE);
extTextView.setVisibility(VISIBLE);
thumbImageView.setVisibility(INVISIBLE);
thumbImageView.setImageBitmap(null);
}
setWillNotDraw(!needDivider);
progressView.setProgress(0, false);
updateFileExistIcon();
}
示例10: updateTitle
import org.telegram.tgnet.TLRPC; //导入方法依赖的package包/类
private void updateTitle(boolean shutdown) {
MessageObject messageObject = MediaController.getInstance().getPlayingMessageObject();
if (messageObject == null && shutdown || messageObject != null && !messageObject.isMusic()) {
if (parentLayout != null && !parentLayout.fragmentsStack.isEmpty() && parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 1) == this) {
finishFragment();
} else {
removeSelfFromStack();
}
} else {
if (messageObject == null) {
return;
}
checkIfMusicDownloaded(messageObject);
updateProgress(messageObject);
if (MediaController.getInstance().isAudioPaused()) {
playButton.setImageResource(R.drawable.player_play_states);
} else {
playButton.setImageResource(R.drawable.player_pause_states);
}
if (actionBar != null) {
SharedPreferences themePrefs = ApplicationLoader.applicationContext.getSharedPreferences(AndroidUtilities.THEME_PREFS, AndroidUtilities.THEME_PREFS_MODE);
int hColor = themePrefs.getInt("themeColor", AndroidUtilities.defColor);
int tColor = hColor != 0xffffffff ? 0xffffffff : 0xff212121;
actionBar.setTitle(messageObject.getMusicTitle());
//actionBar.getTitleTextView().setTextColor(0xff212121);
actionBar.getTitleTextView().setTextColor(tColor);
actionBar.setSubtitle(messageObject.getMusicAuthor());
//actionBar.getSubTitleTextView().setTextColor(0xff8a8a8a);
//actionBar.getSubTitleTextView().setTextColor(tColor);
}
AudioInfo audioInfo = MediaController.getInstance().getAudioInfo();
if (audioInfo != null && audioInfo.getCover() != null) {
placeholder.setImageBitmap(audioInfo.getCover());
placeholder.setPadding(0, 0, 0, 0);
placeholder.setScaleType(ImageView.ScaleType.CENTER_CROP);
} else {
placeholder.setImageResource(R.drawable.nocover);
placeholder.setPadding(0, 0, 0, AndroidUtilities.dp(30));
placeholder.setScaleType(ImageView.ScaleType.CENTER);
}
if (durationTextView != null) {
int duration = 0;
TLRPC.Document document = messageObject.getDocument();
if (document != null) {
for (int a = 0; a < document.attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = document.attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {
duration = attribute.duration;
break;
}
}
}
durationTextView.setText(duration != 0 ? String.format("%d:%02d", duration / 60, duration % 60) : "-:--");
}
}
}