swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swftools-common] stop tag in wav2swf


From: Hartwig, Thomas
Subject: [Swftools-common] stop tag in wav2swf
Date: Wed, 13 Oct 2004 10:20:14 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8a5) Gecko/20041003

For using the FlashsoundAPI at http://www.flashsoundapi.com I needed the stop tag in the end of the SWF file. This is very useful because you don't have to load every sound at page loading, but you can then use the function loadMovieNum(url,layerNumber), this function always loops by default, so there is a stop tag needed.

I have patched the beautiful wav2swf to insert a STOP frame in the end. However this is a dirty hack since I don't understand much of the SWF structure. I attach this to this email, just use or trash it ;-)

Regards
Thomas

*** wav2swf.c   Sun May  9 11:30:13 2004
--- ../../swftools-0.6.2-new/src/wav2swf.c      Tue Oct 12 21:29:41 2004
*************** char * filename = 0;
*** 30,52 ****
  char * outputname = "output.swf";
  int verbose = 2;
  int stopframe0 = 0;

  #define DEFINESOUND_MP3 1 //define sound uses mp3?- undefine for raw sound.

  static struct options_t options[] = {
! {"h", "help"},
! {"V", "version"},
! {"o", "output"},
! {"r", "framerate"},
! {"s", "samplerate"},
! {"b", "bitrate"},
! {"d", "definesound"},
! {"l", "loop"},
! {"C", "cgi"},
! {"S", "stop"},
! {"b", "bitrate"},
! {"v", "verbose"},
! {0,0}
  };

  static int loop = 0;
--- 30,54 ----
  char * outputname = "output.swf";
  int verbose = 2;
  int stopframe0 = 0;
+ int stopframe1 = 0;

  #define DEFINESOUND_MP3 1 //define sound uses mp3?- undefine for raw sound.

  static struct options_t options[] = {
!       {"h", "help"},
!       {"V", "version"},
!       {"o", "output"},
!       {"r", "framerate"},
!       {"s", "samplerate"},
!       {"b", "bitrate"},
!       {"d", "definesound"},
!       {"l", "loop"},
!       {"C", "cgi"},
!       {"S", "stop"},
!       {"E", "end"},
!       {"b", "bitrate"},
!       {"v", "verbose"},
!       {0,0}
  };

  static int loop = 0;
*************** int args_callback_option(char*name,char*
*** 86,91 ****
--- 88,97 ----
                stopframe0 = 1;
                return 0;
        }
+       else if(!strcmp(name, "E")) {
+               stopframe1 = 1;
+               return 0;
+       }
        else if(!strcmp(name, "C")) {
                do_cgi = 1;
                return 0;
*************** void args_callback_usage(char *name)
*** 162,167 ****
--- 168,174 ----
        printf("-l , --loop n                  (Only used with -d)\n");
        printf("-C , --cgi                     For use as CGI- prepend http 
header, write to stdout.\n");
        printf("-S , --stop                    Stop the movie at frame 0\n");
+       printf("-E , --stop                    Stop the movie at end frame\n");
        printf("-b , --bitrate <bps>           Set mp3 bitrate to <bps> 
(default: 32)\n");
        printf("-v , --verbose                 Be more verbose\n");
        printf("\n");
*************** int main (int argc,char ** argv)
*** 317,322 ****
--- 324,338 ----
                                framesamplepos += samplesperframe;
                        }
                }
+               if(stopframe1) {
+                       ActionTAG*action = 0;
+                       tag = swf_InsertTag(tag, ST_DOACTION);
+                       action = action_Stop(action);
+                       action = action_End(action);
+                       swf_ActionSet(tag, action);
+                       swf_ActionFree(action);
+                       tag = swf_InsertTag(tag, ST_SHOWFRAME);
+               }
                tag = swf_InsertTag(tag, ST_END);
        } else {
                SOUNDINFO info;
*************** int main (int argc,char ** argv)
*** 338,345 ****
--- 354,363 ----
                swf_SetSoundInfo(tag, &info);
                tag = swf_InsertTag(tag, ST_SHOWFRAME);
                tag = swf_InsertTag(tag, ST_END);
+
        }

+
        if(do_cgi) {
                if FAILED(swf_WriteCGI(&swf)) fprintf(stderr,"WriteCGI() 
failed.\n");
        } else {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]