Changeset 387

Show
Ignore:
Timestamp:
01/08/2008 01:39:59 (8 months ago)
Author:
why
Message:
  • shoes/ruby.c: added length, time, time=, position and position= methods for seeking within videos.
  • samples/video.rb: added a link for seeking the video.
  • lib/shoes/help.rb: added docs for all the video methods.
Location:
trunk
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/lib/shoes/help.rb

    r385 r387  
    507507The horizontal screen size of the image in pixels. 
    508508 
     509== Video == 
     510 
     511Shoes supports embedding of QuickTime, Flash video (FLV), DivX, Xvid and various other popular video formats.  This is all thanks to VideoLAN and ffmpeg, two sensational open source libraries.  Use the `video` method on a slot to setup a Shoes::Video object. 
     512 
     513In addition to video formats, some audio formats are also supported, such as MP3, WAV and Ogg Vorbis. 
     514 
     515Video support is optional in Shoes and some builds do not support video.  For example, video support is unavailable for PowerPC.  When you download Shoes, the build for your platform will be marked `novideo` in the filename if no video support is available. 
     516 
     517=== hide() » self === 
     518 
     519Hides the video.  If already playing, the video will continue to play.  This just turns off display of the video.  One possible use of this method is to collapse the video area when it is playing an audio file, such as an MP3. 
     520 
     521=== length() » a number === 
     522 
     523The full length of the video in milliseconds.  Returns nil if the video is not yet loaded. 
     524 
     525=== move(x, y) » self === 
     526 
     527Moves the video to specific coordinates, the (x, y) being the upper left hand corner of the video. 
     528 
     529=== pause() » self === 
     530 
     531Pauses the video, if it is playing. 
     532 
     533=== playing?() » true of false === 
     534 
     535Returns true if the video is currently playing.  Or, false if the video is paused or stopped. 
     536 
     537=== play() » self === 
     538 
     539Starts playing the video, if it isn't already playing.  If already playing, the video is restarted from the beginning. 
     540 
     541=== position() » a decimal === 
     542 
     543The position of the video as a decimanl number (a Float) between the beginning (0.0) and the end (1.0).  For instance, a Float value of 0.5 indicates the halfway point of the video. 
     544 
     545=== position = a decimal === 
     546 
     547Sets the position of the video using a Float value.  To move the video to its 25% position: `@video.position = 0.25`. 
     548 
     549=== remove() » self === 
     550 
     551Removes the video from its slot.  This will stop the video as well. 
     552 
     553=== show() » self === 
     554 
     555Reveals the video, if it has been hidden by the `hide()` method. 
     556 
     557=== stop() » self === 
     558 
     559Stops the video, if it is playing. 
     560 
     561=== time() » a number === 
     562 
     563The time position of the video in milliseconds.  So, if the video is 10 seconds into play, this method would return the number 10000. 
     564 
     565=== time = a number === 
     566 
     567Set the position of the video to a time in milliseconds. 
     568 
     569=== toggle() » self === 
     570 
     571Toggles the visibility of the video.  If the video can be seen, then `hide` is called.  Otherwise, `show` is called. 
     572 
    509573END 
  • trunk/samples/video.rb

    r272 r387  
    1 Shoes.app do 
    2   stack do 
     1Shoes.app :width => 408, :height => 334, :resizable => false do 
     2  background "#eee" 
     3  stack :margin => 4 do 
    34    @vid = video "http://whytheluckystiff.net/o..e/adventure_time.flv" 
    4     para "controls: ", 
    5       link("play")  { @vid.play }, ", ", 
    6       link("pause") { @vid.pause }, ", ", 
    7       link("stop")  { @vid.stop }, ", ", 
    8       link("hide")  { @vid.hide }, ", ", 
    9       link("show")  { @vid.show } 
    105  end 
     6  para "controls: ", 
     7    link("play")  { @vid.play }, ", ", 
     8    link("pause") { @vid.pause }, ", ", 
     9    link("stop")  { @vid.stop }, ", ", 
     10    link("hide")  { @vid.hide }, ", ", 
     11    link("show")  { @vid.show }, ", ", 
     12    link("+5 sec") { @vid.time += 5000 } 
    1113end 
  • trunk/shoes/ruby.c

    r384 r387  
    10791079  } 
    10801080 
     1081#define VIDEO_GET_METHOD(x, ctype, rbtype) \ 
     1082  VALUE shoes_video_get_##x(VALUE self) \ 
     1083  { \ 
     1084    shoes_video *self_t; \ 
     1085    Data_Get_Struct(self, shoes_video, self_t); \ 
     1086    if (self_t->init == 1) \ 
     1087    { \ 
     1088      libvlc_input_t *input = libvlc_playlist_get_input(self_t->vlc, NULL); \ 
     1089      if (input != NULL) { \ 
     1090        ctype len = libvlc_input_get_##x(input, &self_t->excp); \ 
     1091        shoes_vlc_exception(&self_t->excp); \ 
     1092        return rbtype(len); \ 
     1093      } \ 
     1094    } \ 
     1095    return Qnil; \ 
     1096  } 
     1097 
     1098#define VIDEO_SET_METHOD(x, rbconv) \ 
     1099  VALUE shoes_video_set_##x(VALUE self, VALUE val) \ 
     1100  { \ 
     1101    shoes_video *self_t; \ 
     1102    Data_Get_Struct(self, shoes_video, self_t); \ 
     1103    if (self_t->init == 1) \ 
     1104    { \ 
     1105      libvlc_input_t *input = libvlc_playlist_get_input(self_t->vlc, NULL); \ 
     1106      if (input != NULL) { \ 
     1107        libvlc_input_set_##x(input, rbconv(val), &self_t->excp); \ 
     1108        shoes_vlc_exception(&self_t->excp); \ 
     1109      } \ 
     1110    } \ 
     1111    return val; \ 
     1112  } 
     1113 
    10811114VIDEO_METHOD(clear); 
    10821115VIDEO_METHOD(prev); 
     
    10841117VIDEO_METHOD(pause); 
    10851118VIDEO_METHOD(stop); 
     1119VIDEO_GET_METHOD(length, vlc_int64_t, INT2NUM); 
     1120VIDEO_GET_METHOD(time, vlc_int64_t, INT2NUM); 
     1121VIDEO_SET_METHOD(time, NUM2INT); 
     1122VIDEO_GET_METHOD(position, float, rb_float_new); 
     1123VIDEO_SET_METHOD(position, NUM2DBL); 
    10861124#endif 
    10871125 
     
    35723610  rb_define_method(cVideo, "pause", CASTHOOK(shoes_video_pause), 0); 
    35733611  rb_define_method(cVideo, "stop", CASTHOOK(shoes_video_stop), 0); 
     3612  rb_define_method(cVideo, "length", CASTHOOK(shoes_video_get_length), 0); 
     3613  rb_define_method(cVideo, "position", CASTHOOK(shoes_video_get_position), 0); 
     3614  rb_define_method(cVideo, "position=", CASTHOOK(shoes_video_set_position), 1); 
     3615  rb_define_method(cVideo, "time", CASTHOOK(shoes_video_get_time), 0); 
     3616  rb_define_method(cVideo, "time=", CASTHOOK(shoes_video_set_time), 1); 
    35743617#endif 
    35753618