Skip to content

Commit

Permalink
Add canPlayFile to OpusFileDecoder
Browse files Browse the repository at this point in the history
  • Loading branch information
Omair Baskanderi committed Jul 6, 2016
1 parent e84caad commit 22e73a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions OrigamiEngine/Plugins/OpusFileDecoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,6 @@

@interface OpusFileDecoder : NSObject <ORGMDecoder>

+ (bool)canPlayFile:(NSString *)path;

@end
14 changes: 14 additions & 0 deletions OrigamiEngine/Plugins/OpusFileDecoder.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ - (void)dealloc {

#pragma mark - ORGMDecoder

+ (bool)canPlayFile:(NSString *)path
{
int error = OPUS_OK;
OggOpusFile *file = op_test_file([path UTF8String], &error);
if (file != NULL)
{
error = op_test_open(file);
op_free(file);

return error == OPUS_OK;
}
return false;
}

+ (NSArray *)fileTypes {
return [NSArray arrayWithObjects:@"opus", nil];
}
Expand Down

0 comments on commit 22e73a7

Please sign in to comment.