info: switch stream callback for compact layout

This commit is contained in:
Stefan Sauer 2011-01-13 11:56:37 +02:00
parent f89638f5b0
commit 173dd47bbb

View file

@ -51,6 +51,10 @@ public class MediaInfo.Info : VPaned
private Discoverer dc;
private Pipeline pb;
private bool have_video = false;
private uint num_video_streams;
private uint cur_video_stream;
private uint num_audio_streams;
private uint cur_audio_stream;
private HashMap<string, string> resolutions;
private HashSet<string> tag_black_list;
@ -188,8 +192,7 @@ public class MediaInfo.Info : VPaned
row++;
all_streams = new Notebook ();
// TODO: needs a bit of cleverness when switching streams
//all_streams.switch_page.connect (on_stream_switched);
all_streams.switch_page.connect (on_stream_switched);
table.attach (all_streams, 0, 3, row, row+1, fill_exp, 0, 0, 1);
row++;
} else {
@ -338,8 +341,9 @@ public class MediaInfo.Info : VPaned
// get stream info
nb = compact_mode ? all_streams : video_streams;
l = info.get_video_streams ();
have_video = (l.length () > 0);
for (int i = 0; i < l.length (); i++) {
num_video_streams = l.length ();
have_video = (num_video_streams > 0);
for (int i = 0; i < num_video_streams; i++) {
sinfo = l.nth_data (i);
caps = sinfo.get_caps ();
@ -461,7 +465,8 @@ public class MediaInfo.Info : VPaned
nb = compact_mode ? all_streams : audio_streams;
l = info.get_audio_streams ();
for (int i = 0; i < l.length (); i++) {
num_audio_streams = l.length ();
for (int i = 0; i < num_audio_streams; i++) {
sinfo = l.nth_data (i);
caps = sinfo.get_caps ();
@ -570,6 +575,7 @@ public class MediaInfo.Info : VPaned
}
// play file
cur_video_stream = cur_audio_stream = 0;
((GLib.Object)pb).set_property ("uri", uri);
pb.set_state (State.PLAYING);
@ -625,7 +631,7 @@ public class MediaInfo.Info : VPaned
/* FIXME: discoverer not neccesarily return the stream in the same order as
* playbin2 sees them: https://bugzilla.gnome.org/show_bug.cgi?id=634407
*/
private void on_video_stream_switched (NotebookPage page, uint page_num)
private void on_video_stream_switched (Notebook nb, NotebookPage page, uint page_num)
{
if (pb.current_state > State.PAUSED) {
stdout.printf ("Switching video to: %u\n", page_num);
@ -633,7 +639,7 @@ public class MediaInfo.Info : VPaned
}
}
private void on_audio_stream_switched (NotebookPage page, uint page_num)
private void on_audio_stream_switched (Notebook nb, NotebookPage page, uint page_num)
{
if (pb.current_state > State.PAUSED) {
stdout.printf ("Switching audio to: %u\n", page_num);
@ -641,6 +647,20 @@ public class MediaInfo.Info : VPaned
}
}
private void on_stream_switched (Notebook nb, NotebookPage page, uint page_num)
{
if (pb.current_state > State.PAUSED) {
if (page_num < num_video_streams) {
stdout.printf ("Switching video to: %u\n", page_num);
((GLib.Object)pb).set_property ("current-video", (int)page_num);
} else {
page_num -= num_video_streams;
stdout.printf ("Switching audio to: %u\n", page_num);
((GLib.Object)pb).set_property ("current-audio", (int)page_num);
}
}
}
private string build_taglist_info (Structure s)
{
uint i;