Class QuickTime::Track
In: ext/exporter.c
lib/quicktime/track.rb
Parent: Object

see ext/track.c for additional methods

Methods

Public Instance methods

Returns true/false depending on if track is an audio track.

[Source]

    # File lib/quicktime/track.rb, line 16
16:     def audio?
17:       media_type == :audio
18:     end

Returns a hash of boundaries. The hash contains four keys: :left, :top, :right, :bottom. Each holds an integer representing the pixel value.

[Source]

/*
  call-seq: bounds() -> bounds_hash
  
  Returns a hash of boundaries. The hash contains four keys: :left, :top, 
  :right, :bottom. Each holds an integer representing the pixel value.
*/
static VALUE track_bounds(VALUE obj)
{
  VALUE bounds_hash = rb_hash_new();
  RgnHandle region;
  Rect bounds;
  region = GetTrackDisplayBoundsRgn(TRACK(obj));
  GetRegionBounds(region, &bounds);
  DisposeRgn(region);
  rb_hash_aset(bounds_hash, ID2SYM(rb_intern("left")), INT2NUM(bounds.left));
  rb_hash_aset(bounds_hash, ID2SYM(rb_intern("top")), INT2NUM(bounds.top));
  rb_hash_aset(bounds_hash, ID2SYM(rb_intern("right")), INT2NUM(bounds.right));
  rb_hash_aset(bounds_hash, ID2SYM(rb_intern("bottom")), INT2NUM(bounds.bottom));
  return bounds_hash;
}

Removes the track from its movie and deletes it from memory.

[Source]

/*
  call-seq: delete()
  
  Removes the track from its movie and deletes it from memory.
*/
static VALUE track_delete(VALUE obj)
{
  DisposeMovieTrack(TRACK(obj));
  return Qnil;
}

Disables the track. See enabled? to determine if it‘s disabled already.

[Source]

/*
  call-seq: disable()
  
  Disables the track. See enabled? to determine if it's disabled already.
*/
static VALUE track_disable(VALUE obj, VALUE boolean)
{
  SetTrackEnabled(TRACK(obj), FALSE);
  return obj;
}

Returns the length of this track in seconds using raw_duration and time_scale.

[Source]

   # File lib/quicktime/track.rb, line 6
6:     def duration
7:       raw_duration.to_f/time_scale
8:     end

Enables the track. See enabled? to determine if it‘s enabled already.

[Source]

/*
  call-seq: enable()
  
  Enables the track. See enabled? to determine if it's enabled already.
*/
static VALUE track_enable(VALUE obj, VALUE boolean)
{
  SetTrackEnabled(TRACK(obj), TRUE);
  return obj;
}

Enable the straight alpha graphic mode for this track.

This is best used on an overlayed video track which includes some alpha transparency (such as in a PNG image).

[Source]

/*
  call-seq: enable_alpha()
  
  Enable the straight alpha graphic mode for this track.
  
  This is best used on an overlayed video track which includes some
  alpha transparency (such as in a PNG image).
*/
static VALUE track_enable_alpha(VALUE obj)
{
  MediaSetGraphicsMode(GetMediaHandler(TRACK_MEDIA(obj)), graphicsModeStraightAlpha, 0);
  return obj;
}

Returns true/false depending on if the track is enabled.

[Source]

/*
  call-seq: enabled?() -> bool
  
  Returns true/false depending on if the track is enabled.
*/
static VALUE track_enabled(VALUE obj, VALUE boolean)
{
  if (GetTrackEnabled(TRACK(obj)) == TRUE) {
    return Qtrue;
  } else {
    return Qfalse;
  }
}

Returns the number of frames in the track.

[Source]

/*
  call-seq: frame_count() -> count
  
  Returns the number of frames in the track.
*/
static VALUE track_frame_count(VALUE obj)
{
  return INT2NUM(GetMediaSampleCount(TRACK_MEDIA(obj)));
}

The average frame_rate for this track. May not be exact.

[Source]

    # File lib/quicktime/track.rb, line 11
11:     def frame_rate # what about odd frame rates such as 29.97?
12:       frame_count/duration
13:     end

Returns the bounding height of this track in number of pixels.

[Source]

    # File lib/quicktime/track.rb, line 36
36:     def height
37:       bounds[:bottom] - bounds[:top]
38:     end

Returns either id number QuickTime uses to reference this track. Usually only used internally.

[Source]

/*
  call-seq: id() -> quicktime_track_id_int
  
  Returns either id number QuickTime uses to reference this track. 
  Usually only used internally.
*/
static VALUE track_id(VALUE obj)
{
  return INT2NUM(GetTrackID(TRACK(obj)));
}

Loads a QuickTime track from a given movie. This is done automatically when calling movie.tracks.

[Source]

/*
  call-seq: load(movie, index)
  
  Loads a QuickTime track from a given movie. This is done automatically 
  when calling movie.tracks.
*/
static VALUE track_load(VALUE obj, VALUE movie_obj, VALUE index_obj)
{
  RTRACK(obj)->track = GetMovieIndTrack(MOVIE(movie_obj), NUM2INT(index_obj));
  if (!RTRACK(obj)->track)
    rb_raise(eQuickTime, "Unable to fetch track for movie at index %d", NUM2INT(index_obj));
  
  return obj;
}

Returns either :audio or :video depending on the type of track this is.

[Source]

/*
  call-seq: media_type() -> media_type_sym
  
  Returns either :audio or :video depending on the type of track this is.
*/
static VALUE track_media_type(VALUE obj)
{
  OSType media_type;
  
  GetMediaHandlerDescription(TRACK_MEDIA(obj), &media_type, 0, 0);
  if (media_type == SoundMediaType) {
    return ID2SYM(rb_intern("audio"));
  } else if (media_type == VideoMediaType) {
    return ID2SYM(rb_intern("video"));
  } else if (media_type == TextMediaType) {
    return ID2SYM(rb_intern("text"));
  } else {
    return Qnil;
  }
}

Creates a new audio media for this track.

Generally this method is not called directly, instead you can make a new audio track using Movie#new_audio_track.

[Source]

/*
  call-seq: new_audio_media()
  
  Creates a new audio media for this track.
  
  Generally this method is not called directly, instead you can make a 
  new audio track using Movie#new_audio_track.
*/
static VALUE track_new_audio_media(VALUE obj)
{
  NewTrackMedia(TRACK(obj), SoundMediaType, 44100, 0, 0);
  return obj;
}

Creates a new text media for this track.

Generally this method is not called directly, instead you can make a new text track using Movie#new_text_track.

[Source]

/*
  call-seq: new_text_media()
  
  Creates a new text media for this track.
  
  Generally this method is not called directly, instead you can make a 
  new text track using Movie#new_text_track.
*/
static VALUE track_new_text_media(VALUE obj)
{
  NewTrackMedia(TRACK(obj), TextMediaType, 600, 0, 0);
  return obj;
}

Creates a new video media for this track.

Generally this method is not called directly, instead you can make a new video track using Movie#new_video_track.

[Source]

/*
  call-seq: new_video_media()
  
  Creates a new video media for this track.
  
  Generally this method is not called directly, instead you can make a 
  new video track using Movie#new_video_track.
*/
static VALUE track_new_video_media(VALUE obj)
{
  NewTrackMedia(TRACK(obj), VideoMediaType, 600, 0, 0);
  return obj;
}

Returns the offset of the track from the beginning of the movie (in seconds).

[Source]

/*
  call-seq: offset() -> seconds
  
  Returns the offset of the track from the beginning of the movie (in seconds).
*/
static VALUE track_get_offset(VALUE obj)
{
  return rb_float_new((double)GetTrackOffset(TRACK(obj))/GetMediaTimeScale(TRACK_MEDIA(obj)));
}

Sets the offset of the track from the start of the movie (in seconds).

[Source]

/*
  call-seq: offset=(seconds)
  
  Sets the offset of the track from the start of the movie (in seconds).
*/
static VALUE track_set_offset(VALUE obj, VALUE seconds)
{
  SetTrackOffset(TRACK(obj), TRACK_TIME(obj, seconds));
  return Qnil;
}

Returns the raw duration of the track. Combine this with time_scale to reach the duration in seconds.

[Source]

/*
  call-seq: raw_duration() -> duration_int
  
  Returns the raw duration of the track. Combine this with time_scale to 
  reach the duration in seconds.
*/
static VALUE track_raw_duration(VALUE obj)
{
  return INT2NUM(GetMediaDuration(TRACK_MEDIA(obj)));
}

Revert any transformations (scale, translate, rotate) performed on this track.

[Source]

/*
  call-seq: reset_transformations()
  
  Revert any transformations (scale, translate, rotate) performed on this track.
*/
static VALUE track_reset_transformations(VALUE obj)
{
  MatrixRecord matrix;
  GetTrackMatrix(TRACK(obj), &matrix);
  SetIdentityMatrix(&matrix);
  SetTrackMatrix(TRACK(obj), &matrix);
  return obj;
}

Rotate the track by the given number of degrees.

[Source]

/*
  call-seq: rotate(degrees)
  
  Rotate the track by the given number of degrees.
*/
static VALUE track_rotate(VALUE obj, VALUE degrees)
{
  MatrixRecord matrix;
  GetTrackMatrix(TRACK(obj), &matrix);
  RotateMatrix(&matrix, FloatToFixed(NUM2DBL(degrees)), 0, 0);
  SetTrackMatrix(TRACK(obj), &matrix);
  return obj;
}

Scale the track‘s size by width and height respectively.

The value passed is a relative float where "1" is the current size.

[Source]

/*
  call-seq: scale(width, height)
  
  Scale the track's size by width and height respectively.
  
  The value passed is a relative float where "1" is the current size.
*/
static VALUE track_scale(VALUE obj, VALUE width, VALUE height)
{
  MatrixRecord matrix;
  GetTrackMatrix(TRACK(obj), &matrix);
  ScaleMatrix(&matrix, FloatToFixed(NUM2DBL(width)), FloatToFixed(NUM2DBL(height)), 0, 0);
  SetTrackMatrix(TRACK(obj), &matrix);
  return obj;
}

Returns true/false depending on if track is a text track.

[Source]

    # File lib/quicktime/track.rb, line 26
26:     def text?
27:       media_type == :text
28:     end

Returns the time scale of the track. Usually only needed when working with raw_duration.

[Source]

/*
  call-seq: time_scale() -> scale_int
  
  Returns the time scale of the track. Usually only needed when working 
  with raw_duration.
*/
static VALUE track_time_scale(VALUE obj)
{
  return INT2NUM(GetMediaTimeScale(TRACK_MEDIA(obj)));
}

Offset a track‘s position by x and y values respectively.

Values should be in pixels.

[Source]

/*
  call-seq: translate(x, y)
  
  Offset a track's position by x and y values respectively.
  
  Values should be in pixels.
*/
static VALUE track_translate(VALUE obj, VALUE x, VALUE y)
{
  MatrixRecord matrix;
  GetTrackMatrix(TRACK(obj), &matrix);
  TranslateMatrix(&matrix, FloatToFixed(NUM2DBL(x)), FloatToFixed(NUM2DBL(y)));
  SetTrackMatrix(TRACK(obj), &matrix);
  return obj;
}

Returns true/false depending on if track is a video track.

[Source]

    # File lib/quicktime/track.rb, line 21
21:     def video?
22:       media_type == :video
23:     end

Returns the volume of the audio from 0.0 to 1.0.

[Source]

/*
  call-seq: volume() -> volume_float
  
  Returns the volume of the audio from 0.0 to 1.0.
*/
static VALUE track_get_volume(VALUE obj)
{
  return rb_float_new((double)GetTrackVolume(TRACK(obj))/0x0100);
}

Sets the volume to the given value (0.0 to 1.0)

[Source]

/*
  call-seq: volume=(volume_float)
  
  Sets the volume to the given value (0.0 to 1.0)
*/
static VALUE track_set_volume(VALUE obj, VALUE volume_obj)
{
  SetTrackVolume(TRACK(obj), (short)(0x0100*NUM2DBL(volume_obj)));
  return Qnil;
}

Returns the bounding width of this track in number of pixels.

[Source]

    # File lib/quicktime/track.rb, line 31
31:     def width
32:       bounds[:right] - bounds[:left]
33:     end

[Validate]