2014-10-27 79 views
0

我试图在我的应用程序中创建一个功能,用户可以通过“拖放”来更改已插入到AVMutableComposition轨道中的已修剪视频的顺序。更改AVMutableCompositionTrack段的顺序

我可以通过使用“segments”属性检索包含轨道的每个段的NSArray,将此数组复制到另一个数组,对新数组进行必要的更改,但无法将新数组分配给AVMutableComposition轨道。

任何想法我该怎么做?

任何帮助将不胜感激。

//retrieving the segments array 
NSMutableArray *compTracksArr = [[NSMutableArray alloc] initWithArray:compTrack.segments]; 
//making changes to the order 
[compTracksArr replaceObjectAtIndex:0 withObject:[compTracksArr lastObject]]; 
//assigning changed array to segments array 
compTrack.segments = [NSArray arrayWithArray:compTracksArr]; 

但是当我尝试的NSLog()来获取输出,compTrack.segments没有表现出它的组件订单的任何更改。

回答

0
/*! 
    @method   validateTrackSegments:error: 
    @abstract  Tests an array of AVCompositionTrackSegments to determine whether they conform 
        to the timing rules noted above (see the property key @"trackSegments"). 
    @param   trackSegments 
        The array of AVCompositionTrackSegments to be validated. 
    @param   error 
        If validation fais, returns information about the failure. 
    @discussion 
     The array is tested for suitability for setting as the value of the trackSegments property. 
     If a portion of an existing trackSegments array is to be modified, the modification can 
     be made via an instance of NSMutableArray, and the resulting array can be tested via 
     -validateTrackSegments:error:. 
*/ 
- (BOOL)validateTrackSegments:(NSArray *)trackSegments error:(NSError **)error; 

这应该给一些答案。