Unable to get Metadata form video using exoplayer without playback - metadata

I am trying to get video metadata using exoplayer without playback as mentioned in document
when i try to run i cannot get list of audio track and subtitle track from local video file.
MediaItem mediaItem = MediaItem.fromUri(videoUrl);
ListenableFuture<TrackGroupArray> trackGroupsFuture = MetadataRetriever.retrieveMetadata(this, mediaItem);
Futures.addCallback(trackGroupsFuture, new FutureCallback<TrackGroupArray>() {
#Override
public void onSuccess(TrackGroupArray trackGroups) {
for(int i = 0; i < trackGroups.length; i++){
String format = trackGroups.get(i).getFormat(0).sampleMimeType;
String lang = trackGroups.get(i).getFormat(0).language;
String id = trackGroups.get(i).getFormat(0).id;
if(format.contains("audio") && id != null && lang != null){
Log.d(TAG, "onSuccess: " + lang + " " + id);
}
}
}
#Override
public void onFailure(Throwable t) {
//handleFailure(t);
Log.d(TAG, "onFailure: " + t);
}
}, executor);
can someone help. How can I get list of tracks available in a video.
here is a sample video link https://storage.googleapis.com/jlplayer/Dolittle.mkv
for example the above sample video contains a english subtitle a hindi audio track and english audio track. So how do i extract those track ?

Related

How do I upload files from a phone to my Amazon S3 server?

I'm developing a mobile app with Unity and using S3 to store and retrieve assets, I can download asset bundles just fine from the server to the phone, but how do I upload files from the phone to the server?
I used the PostObject function from the AWS Unity SDK, and it works fine if I upload from the computer as I know the directory, but I'm not sure how to get the phone's photo gallery to upload to the s3 server.
This is the PostObject function
public void PostObject(string fileName)
{
ResultText.text = "Retrieving the file";
var stream = new FileStream("file://" + Application.streamingAssetsPath + "/" + fileName,
FileMode.Open, FileAccess.Read, FileShare.Read);
Debug.Log("kek");
ResultText.text += "\nCreating request object";
var request = new PostObjectRequest()
{
Bucket = S3BucketName,
Key = fileName,
InputStream = stream,
CannedACL = S3CannedACL.Private,
Region = _S3Region
};
ResultText.text += "\nMaking HTTP post call";
Client.PostObjectAsync(request, (responseObj) =>
{
if (responseObj.Exception == null)
{
ResultText.text += string.Format("\nobject {0} posted to bucket {1}",
responseObj.Request.Key, responseObj.Request.Bucket);
}
else
{
ResultText.text += "\nException while posting the result object";
ResultText.text += string.Format("\n receieved error {0}",
responseObj.Response.HttpStatusCode.ToString());
}
});
}
And this is where I'm using it to upload the picture taken from the phone to the server
public void TakePicture(int maxSize)
{
NativeCamera.Permission permission = NativeCamera.TakePicture((path) =>
{
Debug.Log("Image path: " + path);
if (path != null)
{
// Create a Texture2D from the captured image
Texture2D imageTexture = NativeCamera.LoadImageAtPath(path, maxSize);
if (imageTexture == null)
{
Debug.Log("Couldn't load texture from " + path);
return;
}
//picturePreview.gameObject.SetActive(true);
//picturePreview.texture = imageTexture;
Texture2D readableTexture = DuplicateTexture(imageTexture);
StartCoroutine(AddImageJob(readableTexture));
//Saves taken photo to the Image Gallery
if (isSaveFiles)
{
NativeGallery.SaveImageToGallery(imageTexture, "AReview", "test");
//Upload to Amazon S3
aws.PostObject(imageTexture.name);
aws.PostObject("test");
}
}
}, maxSize);
Debug.Log("Permission result: " + permission);
}
Any clues?
Thank you.

Players are unmuted when relog

I have no idea why my code is not keeping players muted after they relog even though I added them to the config.
This is there the muted players get saved:
private static ArrayList <Player> mutedPlayers = new ArrayList<Player>();
This is the event that handles the muted player and that should check if the player is muted or not:
#EventHandler
public void handlePlayerChat(AsyncPlayerChatEvent e){
Player p = e.getPlayer();
if (mutedPlayers.contains(p)) {
p.sendMessage(ChatColor.DARK_RED + "You've been muted!");
e.setCancelled(true);
}
}
This is the command:
if(command.getName().equals("mute")) {
if (sender instanceof Player) {
Player p = (Player) sender;
if (p.hasPermission("shxr.mute")) {
if (args.length == 1) {
Player target = Bukkit.getPlayer(args[0]);
if (target != null) {
if (!mutedPlayers.contains(target)) {
mutedPlayers.add(target);
p.sendMessage(ChatColor.GREEN + "You have successfully muted " + target.getName() + ChatColor.GREEN + "!");
target.sendMessage(ChatColor.DARK_RED + "You are muted!");
getConfig().set("mutedPlayers.Players", mutedPlayers);
saveConfig();
} else {
mutedPlayers.remove(target);
p.sendMessage(ChatColor.GREEN + target.getName() + ChatColor.GREEN + " has been unmuted!");
target.sendMessage(ChatColor.DARK_RED + "You have been unmuted!");
saveConfig();
}
} else {
p.sendMessage(ChatColor.DARK_RED + "Cannot find the player.");
}
} else {
p.sendMessage(ChatColor.DARK_RED + "Proper usage of this command is: /mute <player>");
}
} else {
p.sendMessage(ChatColor.DARK_RED + "You do not have the permissions to mute players!");
}
}
}
Two issues:
You aren't saving this list to disk, so when the server restarts, you're going to lose it all.
You are storing references to the Player object, which gets recreated any time a user logs in or changes dimensions (Player is just an Entity class and is not a permanent reference). You need to store the user's UUID.

Getting Text from IResult Facebook SDK, 7.2.0

I am trying to get the player's username and then display it.
Recently, there was a breaking changes; IResult replacement for FBResult.
I was able to return a texture from the IGraphResult instead of FBResult, to display the profile picture, so I expect that the Text would be available as well but no.
So my issue is, where can I return the Text from?
Do I have to add anything to the IGraphResult?
Here is the code,
void DealWithUserName(FBResult result)
{
if(result.Error != null)
{
Debug.Log ("Problems with getting profile picture");
FB.API ("/me?fields=id,first_name", HttpMethod.GET, DealWithUserName);
return;
}
profile = Util.DeserializeJSONProfile(result.Text);
Text UserMsg = UIFBUsername.GetComponent<Text>();
UserMsg.text = "Hello, " + profile["first_name"];
}
Edited:
Okay, I did it.
It seems that I can also get the username from the IGraphResult.
So, I changed the FBResult to IGraphResult.
I changed result.Text to result.RawResult.
Here is the code, for anyone who needs it.
void DealWithUserName(IGraphResult result)
{
if(result.Error != null)
{
Debug.Log ("Problems with getting profile picture");
FB.API ("/me?fields=id,first_name", HttpMethod.GET, DealWithUserName);
return;
}
profile = Util.DeserializeJSONProfile(result.RawResult);
Text UserMsg = UIFBUsername.GetComponent<Text>();
UserMsg.text = "Hello, " + profile["first_name"];
}
Let's try it
private void DealWithUserName(IGraphResult result){
if (result.ResultDictionary != null) {
foreach (string key in result.ResultDictionary.Keys) {
Debug.Log(key + " : " + result.ResultDictionary[key].ToString());
// first_name : Chris
// id : 12345678901234567
}
}
Text UserName = UIUserName.GetComponent<Text>();
UserName.text = "Hello, "+ result.ResultDictionary["name"].ToString();
}

How to get high quality image avatar smack xmpp facebook

I used Vcard smack for get avatar image but it return to me image avatar size 32*32
It small image so I want to get high quality such as facebook do or other app do
could someone help me?
I try to search in gooogle but almost of thread said using Vcard for get avatar
I use to method below for get avatar with Vcard
=> my solution is using graphic api from facebook:
String urlAvatar = "https://graph.facebook.com/" + StringUtils.parseName(childrenEntryItems.getJid()).
replace("-", "") + "/picture?type=normal";
public static byte[] getAvatarByteArray(XMPPConnection xmppConnection, String user) {
VCard vCard = new VCard();
SmackConfiguration.setPacketReplyTimeout(30000);
// ProviderManager.getInstance().addIQProvider("vCard", "vcard-temp",
// new VCardProvider());
try {
vCard.load(xmppConnection, user);
} catch (XMPPException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
// Log.d("Giang", vCard.toXML() + " byte length = "
// + vCard.getAvatar().length); // complete VCard information
return vCard.getAvatar();
}
public static Bitmap makeBitemap(byte[] value) {
if (value == null)
return null;
// Load only size values
BitmapFactory.Options sizeOptions = new BitmapFactory.Options();
sizeOptions.inJustDecodeBounds = true;
BitmapFactory.decodeByteArray(value, 0, value.length, sizeOptions);
// Calculate factor to down scale image
int scale = 1;
int width_tmp = sizeOptions.outWidth;
int height_tmp = sizeOptions.outHeight;
while (width_tmp / 2 >= 256 && height_tmp / 2 >= 256) {
scale *= 2;
width_tmp /= 2;
height_tmp /= 2;
}
// Load image
BitmapFactory.Options resultOptions = new BitmapFactory.Options();
resultOptions.inSampleSize = scale;
return BitmapFactory.decodeByteArray(value, 0, value.length,
resultOptions);
}
I think the best deal would be to store url of avatar in one of the custom v-cards and fetch it over HTTP using some image loading library. Remember that xmpp is a stream based architecture and I would be cautious to block the stream by sending large files.

Wicket download link

On the Wicket page I have an image (AbstractDefaultAjaxBehavior.INDICATOR) which is shown on submit and then i start a AjaxSelfUpdatingTimerBehavior to monitor a file.
Now I also have a DownloadLink to download the same file. However after download the image which I mentioned above (which is rotating) stops rotating. Is there a solution to this issue? I am new to wicket. Please suggest.
public LoggingPage() {
Form<Void> form;
this.add(form = new Form<Void>("resourceForm") {
private static final long serialVersionUID = 1L;
#Override
protected void onSubmit() {
submit();
}
});
add(new DownloadLink("downloadButton", new AbstractReadOnlyModel<File>()
{
private static final long serialVersionUID = 1L;
#Override
public File getObject()
{
File file;
try
{
file = new File(LoggingPage.this.fileDetail.getLocation());
}
catch (Exception e)
{
throw new RuntimeException(e);
}
return file;
}
}));
}//cons ends
private void submit() {
if (this.serverDetail != null && this.fileType != null && this.fileDetail != null)
{
if (this.fileViewer != null)
{
this.repeater.removeAll();
}
File file = new File(this.fileDetail.getLocation());
file = new File("C:/ueshome/logs/safe.log");
this.fileViewer = new FileViewer(file);
this.fileViewer.startTailing();
log.debug("load of allLog: " + this.fileViewer.getOldLog());
buildItem(this.fileViewer.getOldLog().getLog().toString());
this.container.add(new AjaxSelfUpdatingTimerBehavior(Duration.seconds(1))
{
#Override
protected void onPostProcessTarget(final AjaxRequestTarget target)
{
target.appendJavascript("$('#container').scrollTop( 999999999 )");
log.debug("onPostProcessTarget: " + LoggingPage.this.fileViewer.hashCode() + "at: " + System.currentTimeMillis());
final FileAttributes fileAttributes = LoggingPage.this.fileViewer.getNewLog();
String newLog = fileAttributes.getLog().toString();
log.debug("nextlog inside load()");
if (newLog != null && newLog.trim().length() > 0)
{
log.debug("~~~~~~~~~~~~~~~~~~~~````*****:" + newLog);
log.debug("String.valueOf(fileAttributes.getSize()))~~~~~~~~~~~~~~~~~~~~````*****:" + String.valueOf(fileAttributes.getSize()));
log.debug("String.valueOf(fileAttributes.getLastModified()): " + String.valueOf(fileAttributes.getLastModified()));
if (LoggingPage.this.repeater.getSizeInBytes() >= logSize)
{
LoggingPage.this.repeater.removeAll();
}
Component item = buildItem(newLog);
target.prependJavascript(String.format(
"var item=document.createElement('%s');item.id='%s';Wicket.$('%s').appendChild(item);",
"div", item.getMarkupId(), LoggingPage.this.container.getMarkupId()));
// LoggingPage.this.imgContainer.setVisible(true);
// target.addComponent(LoggingPage.this.imgContainer);
target.addComponent(item);
target.appendJavascript("$('#fileAttributesContainer').show(); ");
target.appendJavascript("$('#container').scrollTop( 999999999 )");
target.appendJavascript("$('#imageContainer').show(); ");
}
else
{
target.appendJavascript("$('#fileAttributesContainer').show(); ");
target.appendJavascript("$('#container').scrollTop( 999999999 )");
target.appendJavascript("$('#imageContainer').show(); ");
}
target.appendJavascript("alert('You are in Ajax Self')");
}
First I have to admit that I have no idea right now what could be wrong with your code. It looks rather different than how I would solve your task.
As I understand you want to have a image (an animated gif) that is animated after the user hits the submit button, right. And it should stop the animation after a certain condition is met (file generation finished etc.). Also you want to have a download link for your file.
What I would do is
use a animated gif that will be shown
add a AjaxSelfUpdatingTimerBehavior that checks your file and if a certain condition is met it changes the image (maybe by changing the image itself, sets the visibility of the image or by changing some css attribute for the image container)
for the file download I would use an ajax button or if nothing should be changed on your side a normal link that delivers an resource stream for your file
Hope this helps a little bit.