Self-contained Movie Handle?

Ask a Question related to Mac Programming, Design and Development.

  1. #1

    Default Self-contained Movie Handle?


    I want to put a movie file into a single self-contained handle that I can
    store and retrieve and play back. PutMovieIntoHandle wont work because it
    does not put the movie *data* into the handle.

    I tried flattening the movie into a handle with FlattenMovieData as shown in
    <[url]http://developer.apple.com/samplecode/Sample_Code/QuickTime/Importers_and_E[/url]
    xporters/qtflattentohandle.htm>

    It appears to make a flat movie handle, but then I can't seem to make a
    movie from it. NewMovieFromDataRef returns noMovieFound.

    How can I turn the handle back into a movie?
    Or, how else should I make the handle?

    Thanks.


    Handle TestMovieFileToHandle(FSSpec* spec)
    {
    OSErr err = noErr;
    Movie movie = NULL;
    Movie flatMovie = NULL;
    Movie newMovie = NULL;
    short refnum = 0;
    short resID = 0;
    Boolean changed = false;
    Str255 movieName = "\p";
    Handle h = NULL;
    DataReferenceRecord dataRefRec;

    err = OpenMovieFile(spec, &refnum, fsRdPerm);
    err = NewMovieFromFile( &movie,
    refnum,
    &resID,
    movieName,
    newMovieActive,
    &changed);

    dataRefRec.dataRefType = HandleDataHandlerSubType;
    dataRefRec.dataRef = NewHandle(sizeof(Handle));

    h = NewHandle(0);
    *((Handle*)(*dataRefRec.dataRef)) = h;

    flatMovie = FlattenMovieData( movie,
    flattenFSSpecPtrIsDataRefRecordPtr,
    (FSSpec *)&dataRefRec,
    0,
    smSystemScript,
    0);

    // flatMovie looks OK
    // Verify there is data in our handle
    long hSize = GetHandleSize(h);
    // Yep, about 14KB
    // Now, see if we can create a movie from our h handle

    err = NewMovieFromDataRef( &newMovie,
    newMovieActive,
    NULL,
    h,
    HandleDataHandlerSubType);

    // Nope, err is -2048 (noMovieFound) :-(

    return h;
    }

    Terry Guest

  2. Similar Questions and Discussions

    1. Handle 3D Quicktime Movie
      Hi, I have couple of 3D quicktime movies (.mov) and wanted to know how to plug them inside director movie (either by importing them inside director...
    2. ViewState of Contained Controls?
      I've built my tab control, and it works great. Except for one problem. Any controls which are contained in any of the tabs lose state. The tab...
    3. Self-Contained Movie-Clip as Menu?
      hi all, wondering if anyone has any advice: i've created a menu for my project that basically rolls on-screen from the left with 6...
    4. value contained within a variable contained within another variable
      I may be way off track with what I am trying to do, but here is my scenario and I sure appreciate any insights. There is a string stored in...
    5. Accessing Assemblies not contained in the Web App
      Hello, I created a simple C# library assembly that exposes general facilities I would like to use in my ASP.NET web applications. If I added the...
  3. #2

    Default Re: Self-contained Movie Handle?

    In article <BB970129.1F844%a@b.com>, Terry <a@b.com> wrote:
    > It appears to make a flat movie handle, but then I can't seem to make a
    > movie from it. NewMovieFromDataRef returns noMovieFound.
    >
    > How can I turn the handle back into a movie?
    > Or, how else should I make the handle?
    > dataRefRec.dataRefType = HandleDataHandlerSubType;
    > dataRefRec.dataRef = NewHandle(sizeof(Handle));
    >
    > h = NewHandle(0);
    > *((Handle*)(*dataRefRec.dataRef)) = h;
    >
    > flatMovie = FlattenMovieData( movie,
    > flattenFSSpecPtrIsDataRefRecordPtr,
    > (FSSpec *)&dataRefRec,
    > 0,
    > smSystemScript,
    > 0);
    >
    > // flatMovie looks OK
    > // Verify there is data in our handle
    > long hSize = GetHandleSize(h);
    > // Yep, about 14KB
    > // Now, see if we can create a movie from our h handle
    >
    > err = NewMovieFromDataRef( &newMovie,
    > newMovieActive,
    > NULL,
    > h, // <-- bug
    > HandleDataHandlerSubType);
    >
    I've pointed you at your bug, above.

    h is not a data ref. dataRefRec.dataRef is. NewMovieFromDataRef wants a
    data ref.
    David Phillip Oster Guest

  4. #3

    Default Re: Self-contained Movie Handle?


    Thanks David. That was indeed a problem. I also needed to use the flag
    flattenAddMovieToDataFork. And, if I ever try to use a saved copy of the
    handle, I have to do this:

    long trackCount = GetMovieTrackCount(newMovie);
    long track;
    for (track=1;track<=trackCount;track++) {
    Media media = GetTrackMedia(GetMovieIndTrack(newMovie, track));
    short dataRefCount = 0;
    GetMediaDataRefCount(media, &dataRefCount);
    long dref;
    for (dref=1;dref<=dataRefCount;dref++) {
    err = SetMediaDataRef( media,
    dref,
    dataReferenceHandle,
    HandleDataHandlerSubType );
    } }


    Now, this all works in my app. But, I would like it if I could put the
    handle data on the clipboard as a 'moov' and paste it into QT Player, or the
    scrapbook. I can almost get it to work if I include the flag
    flattenForceMovieResourceBeforeMovieData. The scrapbook and QT Player know
    the size and number of frames and act like they can play it, but there are
    no images -- everything is blank.

    IF I use the original handle (not a copy) made by FlattenMovieData, then the
    movies draw and play in QT Player, but only until my app disposes of ITS
    handle.

    Is there any way to fix this?

    Thanks.




    > In article <BB970129.1F844%a@b.com>, Terry <a@b.com> wrote:
    >
    >> It appears to make a flat movie handle, but then I can't seem to make a
    >> movie from it. NewMovieFromDataRef returns noMovieFound.
    >>
    >> How can I turn the handle back into a movie?
    >> Or, how else should I make the handle?
    >
    >> dataRefRec.dataRefType = HandleDataHandlerSubType;
    >> dataRefRec.dataRef = NewHandle(sizeof(Handle));
    >>
    >> h = NewHandle(0);
    >> *((Handle*)(*dataRefRec.dataRef)) = h;
    >>
    >> flatMovie = FlattenMovieData( movie,
    >> flattenFSSpecPtrIsDataRefRecordPtr,
    >> (FSSpec *)&dataRefRec,
    >> 0,
    >> smSystemScript,
    >> 0);
    >>
    >> // flatMovie looks OK
    >> // Verify there is data in our handle
    >> long hSize = GetHandleSize(h);
    >> // Yep, about 14KB
    >> // Now, see if we can create a movie from our h handle
    >>
    >> err = NewMovieFromDataRef( &newMovie,
    >> newMovieActive,
    >> NULL,
    >> h, // <-- bug
    >> HandleDataHandlerSubType);
    >>
    >
    > I've pointed you at your bug, above.
    >
    > h is not a data ref. dataRefRec.dataRef is. NewMovieFromDataRef wants a
    > data ref.
    Terry Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139