summaryrefslogtreecommitdiff
path: root/SwfdecExamples.mdwn
blob: 4bb8d1f9318121458e2ce9bc3a5cd6d6cd2f7f27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103


# SWFDEC Examples

The examples section.  

---

 **Version 0.8.0** 


##### Create a minimal gtk-based player with informations


[[!format txt """
//Created by : pepsidrinker@hotmail.com
// Date : Sept. 15 2008

#include <swfdec-gtk/swfdec-gtk.h>


/*
Simple SWFDEC ---> version 0.8.0 <---- playback tutorial :
This tutorial may contain error(s) and/or ugly code.
It is not optimized at all.
Feel free to change it as you wish
*/

static void
playback_aborted (SwfdecPlayer *player)
{
  if (swfdec_player_is_initialized (player))
    g_print ("Given file is not a Flash file.");
  else
    g_print ("Broken Flash file.");

  gtk_main_quit();
}

static void
print_infos (SwfdecPlayer *player)
{
  guint h,w;

  //SWFDEC_PLAYER type infos
  g_print("Max runtime : %lu\n",swfdec_player_get_maximum_runtime (player));
  swfdec_player_get_default_size(player,&h,&w);
  g_print("Size: %d, %d\n",h,w);
  g_print("BG Color : %d\n",swfdec_player_get_background_color(player));
  g_print("Rate: %f\n",swfdec_player_get_rate(player));
 
  //SWFDEC_GTK_PLAYER type infos
  g_print("Speed :%f\n",swfdec_gtk_player_get_speed (SWFDEC_GTK_PLAYER(player)));
  g_print("Audio enabled : %d\n",swfdec_gtk_player_get_audio_enabled (SWFDEC_GTK_PLAYER(player)));
  g_print("Is playing :%d\n",swfdec_gtk_player_get_playing(SWFDEC_GTK_PLAYER(player)));
}


int 
main (int argc, char **argv)
{
  SwfdecPlayer *player;
  // GTK init stuff
  GtkWidget *window, *widget;
  gtk_init (&argc, &argv);
  
  if (argc < 2) 
  {
    g_print ("usage: %s file://PATH or URL", argv[0]);
    // Ex: file://foobar.swf OR http://www.foo.bar/foobar.swf
    return 1;
  }
  
  //Create a new player
  player = swfdec_gtk_player_new (NULL);

  //Pass out the URL or File Path
  SwfdecURL* url = swfdec_url_new(argv[1]);
  swfdec_player_set_url(player,url);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  widget = swfdec_gtk_widget_new (player);
  gtk_container_add (GTK_CONTAINER (window), widget);
  gtk_widget_show_all (window);

  //Get notifications
  g_signal_connect (player, "notify::initialized", G_CALLBACK (print_infos), NULL);
  g_signal_connect (player, "notify::aborted", G_CALLBACK (playback_aborted), NULL);

  //Play !
  swfdec_gtk_player_set_playing (SWFDEC_GTK_PLAYER (player), TRUE);
  
  //GTK main loop
  gtk_main ();

  return 0;
}
"""]]


---