Commit 0a27f7b6 authored by Sébastien Toque's avatar Sébastien Toque

Fill media tracks info

parent 862fe417
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:scrollbars="none">
<FrameLayout
android:orientation="vertical"
android:orientation="vertical" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="48dip"
android:background="@drawable/header"
android:orientation="horizontal" >
<ImageView
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:gravity="center_horizontal"
android:paddingTop="60dip">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyleLarge" />
</LinearLayout>
android:scaleType="centerInside"
android:src="@drawable/header_logo" />
</LinearLayout>
<FrameLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<ProgressBar
style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center" />
<ImageView
android:layout_width="fill_parent"
android:layout_height="230dip"
android:id="@+id/image"
android:scaleType="fitCenter"
android:visibility="invisible" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:scaleType="fitCenter" />
<TextView
android:id="@+id/title"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="180dip">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="#66000000">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceLarge"
android:id="@+id/title"
android:singleLine="true"
android:layout_marginLeft="10dip" />
<TextView
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:gravity="right"
android:id="@+id/length"
android:layout_marginRight="10dip"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/stream_0" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/stream_1" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:textAppearance="?android:attr/textAppearanceSmall" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginTop="10dip"
android:layout_marginLeft="5dip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text="@string/stream_2" />
<TextView
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_marginLeft="20dip"
android:textAppearance="?android:attr/textAppearanceSmall"
android:layout_marginBottom="30dip" />
</LinearLayout>
</LinearLayout>
android:layout_height="wrap_content"
android:background="@drawable/video_list_length_bg"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/length"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|right"
android:layout_margin="10dip"
android:background="@drawable/video_list_length_bg"
android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>
</ScrollView>
<ListView
android:id="@id/android:list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:cacheColorHint="#00000000"
android:divider="#00000000"
android:fastScrollEnabled="true" />
</LinearLayout>
\ No newline at end of file
......@@ -45,9 +45,6 @@
<string name="album">Album</string>
<string name="directory">Répertoire</string>
<string name="directories">Répertoires</string>
<string name="stream_0">Flux 0</string>
<string name="stream_1">Flux 1</string>
<string name="stream_2">Flux 2</string>
<string name="loading">Chargement…</string>
<string name="nomedia">Pas de fichiers multimédia</string>
<string name="mediafiles">Fichiers multimédia</string>
......@@ -69,4 +66,13 @@
<string name="detect_headset">Détecter le casque</string>
<string name="detect_headset_detail">Pause lors du débranchement du casque, Reprise lors du branchement du casque</string>
<string name="refresh">Rafraîchir</string>
<string name="track_audio">Piste audio</string>
<plurals name="track_audio_info">
<item quantity="one">Codec: %1$s\n%2$d canal\nFréquence d\'échantillonage: %3$d Hz</item>
<item quantity="other">Codec: %1$s\n%2$d canaux\nFréquence d\'échantillonage: %3$d Hz</item>
</plurals>
<string name="track_video">Piste vidéo</string>
<string name="track_video_info">Codec: %1$s\nRésolution: %2$dx%3$d</string>
<string name="track_text">Piste sous-titres</string>
<string name="track_unknown">Piste inconnue</string>
</resources>
......@@ -46,9 +46,6 @@
<string name="album">Album</string>
<string name="directory">Directory</string>
<string name="directories">Directories</string>
<string name="stream_0">Stream 0</string>
<string name="stream_1">Stream 1</string>
<string name="stream_2">Stream 2</string>
<string name="loading">Loading…</string>
<string name="nomedia">No media files</string>
<string name="mediafiles">Media files</string>
......@@ -71,4 +68,13 @@
<string name="detect_headset">Detect headset</string>
<string name="detect_headset_detail">Pause on headset removed, Resume on headset inserted</string>
<string name="refresh">Refresh</string>
<string name="track_audio">Audio track</string>
<plurals name="track_audio_info">
<item quantity="one">Codec: %1$s\n%2$d channel\nSample rate: %3$d Hz</item>
<item quantity="other">Codec: %1$s\n%2$d channels\nSample rate: %3$d Hz</item>
</plurals>
<string name="track_video">Video track</string>
<string name="track_video_info">Codec: %1$s\nResolution: %2$dx%3$d</string>
<string name="track_text">Subtitles track</string>
<string name="track_unknown">Unknown track</string>
</resources>
......@@ -197,6 +197,10 @@ public class LibVLC {
return readMediaMeta(mLibVlcInstance, mrl);
}
public TrackInfo[] readTracksInfo(String mrl) {
return readTracksInfo(mLibVlcInstance, mrl);
}
/**
* Get a media thumbnail.
*/
......
......@@ -2,10 +2,10 @@ package org.videolan.vlc;
public class TrackInfo {
protected static final int TYPE_UNKNOWN = -1;
protected static final int TYPE_AUDIO = 0;
protected static final int TYPE_VIDEO = 1;
protected static final int TYPE_TEXT = 2;
public static final int TYPE_UNKNOWN = -1;
public static final int TYPE_AUDIO = 0;
public static final int TYPE_VIDEO = 1;
public static final int TYPE_TEXT = 2;
public int Type;
public int Id;
......
......@@ -27,9 +27,10 @@ import org.videolan.vlc.LibVlcException;
import org.videolan.vlc.Media;
import org.videolan.vlc.MediaLibrary;
import org.videolan.vlc.R;
import org.videolan.vlc.TrackInfo;
import org.videolan.vlc.Util;
import android.app.Activity;
import android.app.ListActivity;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.os.Bundle;
......@@ -38,11 +39,14 @@ import android.os.Message;
import android.widget.ImageView;
import android.widget.TextView;
public class MediaInfoActivity extends Activity {
public class MediaInfoActivity extends ListActivity {
public final static String TAG = "VLC/MediaInfoActivity";
private Media mItem;
private Bitmap mImage;
private TrackInfo[] mTracks;
private MediaInfoAdapter mAdapter;
private final static int NEW_IMAGE = 0;
private final static int NEW_TEXT = 1;
@Override
protected void onCreate(Bundle savedInstanceState) {
......@@ -61,8 +65,10 @@ public class MediaInfoActivity extends Activity {
TextView lengthView = (TextView) findViewById(R.id.length);
lengthView.setText(Util.millisToString(mItem.getLength()));
new Thread(mLoadImage).start();
mAdapter = new MediaInfoAdapter(MediaInfoActivity.this, R.layout.audio_browser_playlist);
setListAdapter(mAdapter);
new Thread(mLoadImage).start();
}
Runnable mLoadImage = new Runnable() {
......@@ -75,9 +81,12 @@ public class MediaInfoActivity extends Activity {
return;
}
mTracks = mLibVlc.readTracksInfo(mItem.getPath());
mHandler.sendEmptyMessage(NEW_TEXT);
int width = Math.min(getWindowManager().getDefaultDisplay().getWidth(),
getWindowManager().getDefaultDisplay().getHeight());
int height = width;
getWindowManager().getDefaultDisplay().getHeight());
int height = width * 9 / 16;
// Get the thumbnail.
mImage = Bitmap.createBitmap(width, height, Config.ARGB_8888);
......@@ -121,13 +130,16 @@ public class MediaInfoActivity extends Activity {
public void handleMessage(Message msg) {
switch (msg.what) {
case NEW_IMAGE:
ImageView imageView =
(ImageView) MediaInfoActivity.this.findViewById(R.id.image);
imageView.setImageBitmap(mImage);
imageView.setVisibility(ImageView.VISIBLE);
break;
}
};
ImageView imageView = (ImageView) MediaInfoActivity.this.findViewById(R.id.image);
imageView.setImageBitmap(mImage);
break;
case NEW_TEXT:
for (TrackInfo track : mTracks) {
mAdapter.add(track);
}
break;
}
};
};
......
package org.videolan.vlc.gui.video;
import org.videolan.vlc.R;
import org.videolan.vlc.TrackInfo;
import android.content.Context;
import android.content.res.Resources;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
public class MediaInfoAdapter extends ArrayAdapter<TrackInfo> {
public MediaInfoAdapter(Context context, int textViewResourceId) {
super(context, textViewResourceId);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View v = convertView;
if (v == null) {
LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = inflater.inflate(R.layout.audio_browser_playlist, parent, false);
holder = new ViewHolder();
holder.title = (TextView) v.findViewById(R.id.title);
holder.text = (TextView) v.findViewById(R.id.text);
v.setTag(holder);
} else
holder = (ViewHolder) v.getTag();
TrackInfo track = getItem(position);
String title;
String text;
Resources res = getContext().getResources();
switch (track.Type)
{
case TrackInfo.TYPE_AUDIO:
title = res.getString(R.string.track_audio);
text = res.getQuantityString(R.plurals.track_audio_info, track.Channels, track.Codec, track.Channels, track.Samplerate);
break;
case TrackInfo.TYPE_VIDEO:
title = res.getString(R.string.track_video);
text = res.getString(R.string.track_video_info, track.Codec, track.Width, track.Height);
break;
case TrackInfo.TYPE_TEXT:
title = res.getString(R.string.track_text);
text = track.Codec;
break;
default:
title = res.getString(R.string.track_unknown);
text = "";
}
holder.title.setText(title);
holder.text.setText(text);
return v;
}
static class ViewHolder {
TextView title;
TextView text;
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment