Audio farts.

slight change

modified pbxproj to clean up resources

reset developmentteam in pbxproj back to what it was before

deleted one line
pull/1/head
Joyce Yan 10 years ago committed by Frederic Jacobs
parent ccdc4b5d17
commit b494b71dbc

@ -287,6 +287,10 @@
AA0C8E498E2046B0B81EEE6E /* libPods.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 8313AE91B4954215858A5662 /* libPods.a */; };
AD41D7B51A6F6F0600241130 /* play_button.png in Resources */ = {isa = PBXBuildFile; fileRef = AD41D7B31A6F6F0600241130 /* play_button.png */; };
AD41D7B61A6F6F0600241130 /* play_button@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = AD41D7B41A6F6F0600241130 /* play_button@2x.png */; };
B10C9B5F1A7049EC00ECA2BF /* pause_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = B10C9B5B1A7049EC00ECA2BF /* pause_icon.png */; };
B10C9B601A7049EC00ECA2BF /* pause_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B10C9B5C1A7049EC00ECA2BF /* pause_icon@2x.png */; };
B10C9B611A7049EC00ECA2BF /* play_icon.png in Resources */ = {isa = PBXBuildFile; fileRef = B10C9B5D1A7049EC00ECA2BF /* play_icon.png */; };
B10C9B621A7049EC00ECA2BF /* play_icon@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = B10C9B5E1A7049EC00ECA2BF /* play_icon@2x.png */; };
B6019E971A2492AB001118DF /* NSDate+millisecondTimeStamp.mm in Sources */ = {isa = PBXBuildFile; fileRef = B6019E961A2492AB001118DF /* NSDate+millisecondTimeStamp.mm */; };
B60C16651988999D00E97A6C /* VersionMigrations.m in Sources */ = {isa = PBXBuildFile; fileRef = B60C16641988999D00E97A6C /* VersionMigrations.m */; };
B60EDE041A05A01700D73516 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B60EDE031A05A01700D73516 /* AudioToolbox.framework */; };
@ -881,6 +885,10 @@
A5E9D4BA1A65FAD800E4481C /* TSVideoAttachmentAdapter.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TSVideoAttachmentAdapter.h; sourceTree = "<group>"; };
AD41D7B31A6F6F0600241130 /* play_button.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = play_button.png; sourceTree = "<group>"; };
AD41D7B41A6F6F0600241130 /* play_button@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "play_button@2x.png"; sourceTree = "<group>"; };
B10C9B5B1A7049EC00ECA2BF /* pause_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = pause_icon.png; sourceTree = "<group>"; };
B10C9B5C1A7049EC00ECA2BF /* pause_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pause_icon@2x.png"; sourceTree = "<group>"; };
B10C9B5D1A7049EC00ECA2BF /* play_icon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = play_icon.png; sourceTree = "<group>"; };
B10C9B5E1A7049EC00ECA2BF /* play_icon@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "play_icon@2x.png"; sourceTree = "<group>"; };
B6019E951A2492AB001118DF /* NSDate+millisecondTimeStamp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSDate+millisecondTimeStamp.h"; sourceTree = "<group>"; };
B6019E961A2492AB001118DF /* NSDate+millisecondTimeStamp.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = "NSDate+millisecondTimeStamp.mm"; sourceTree = "<group>"; };
B60C16631988999D00E97A6C /* VersionMigrations.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = VersionMigrations.h; sourceTree = "<group>"; };
@ -2128,6 +2136,10 @@
B633C4FD1A1D190B0059AC12 /* Images */ = {
isa = PBXGroup;
children = (
B10C9B5B1A7049EC00ECA2BF /* pause_icon.png */,
B10C9B5C1A7049EC00ECA2BF /* pause_icon@2x.png */,
B10C9B5D1A7049EC00ECA2BF /* play_icon.png */,
B10C9B5E1A7049EC00ECA2BF /* play_icon@2x.png */,
AD41D7B31A6F6F0600241130 /* play_button.png */,
AD41D7B41A6F6F0600241130 /* play_button@2x.png */,
FC3BD9851A30A62D005B96BB /* twitter@2x.png */,
@ -2917,6 +2929,7 @@
FC5CDF391A3393DD00B47253 /* error_white@2x.png in Resources */,
B633C5851A1D190B0059AC12 /* blue-archive@2x.png in Resources */,
B633C5D21A1D190B0059AC12 /* savephoto@2x.png in Resources */,
B10C9B611A7049EC00ECA2BF /* play_icon.png in Resources */,
B633C5921A1D190B0059AC12 /* contacts_tab@2x.png in Resources */,
B6416FB8199A0478003C5699 /* Localizable.strings in Resources */,
FCB626A51A3B00FA00FDB504 /* info@2x.png in Resources */,
@ -2945,12 +2958,14 @@
FCA52B071A2BBAE400CCADFA /* call_tab@2x.png in Resources */,
B633C58D1A1D190B0059AC12 /* contact_default_feed.png in Resources */,
FC3BD97C1A2CD385005B96BB /* signal_dotted@2x.png in Resources */,
B10C9B621A7049EC00ECA2BF /* play_icon@2x.png in Resources */,
B633C5CD1A1D190B0059AC12 /* photo@2x.png in Resources */,
A507A3B01A6C60E300BEED0D /* ContactTableViewCell.xib in Resources */,
B633C5861A1D190B0059AC12 /* call@2x.png in Resources */,
B67EBF5D19194AC60084CCFD /* Settings.bundle in Resources */,
E1370BE418A0686C00826894 /* outring.mp3 in Resources */,
B633C5841A1D190B0059AC12 /* backspace@2x.png in Resources */,
B10C9B601A7049EC00ECA2BF /* pause_icon@2x.png in Resources */,
B6C6AE551A305ED1006BAF8F /* redphone.cer in Resources */,
B633C5B71A1D190B0059AC12 /* logo_intro@2x.png in Resources */,
E1370BE518A0686C00826894 /* r.caf in Resources */,
@ -2962,6 +2977,7 @@
B633C58F1A1D190B0059AC12 /* contacts@2x.png in Resources */,
E1370BE618A0686C00826894 /* sonarping.mp3 in Resources */,
B633C5961A1D190B0059AC12 /* DefaultContactImage.png in Resources */,
B10C9B5F1A7049EC00ECA2BF /* pause_icon.png in Resources */,
E148751218A06AFD002CC4F3 /* HelveticaNeueLTStd-Bd.otf in Resources */,
FCA52AE61A2B676C00CCADFA /* call_canceled@2x.png in Resources */,
FC3BD9861A30A62D005B96BB /* twitter@2x.png in Resources */,

Binary file not shown.

After

Width:  |  Height:  |  Size: 941 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 955 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

@ -21,7 +21,7 @@
- (BOOL)isImage;
- (BOOL)isVideo;
-(NSURL*)videoURL;
-(NSURL*)mediaURL;
+ (void)deleteAttachments;
@end

@ -62,7 +62,7 @@ NSString * const TSAttachementFileRelationshipEdge = @"TSAttachementFileEdge";
}
}
-(NSURL*) videoURL {
-(NSURL*) mediaURL {
return [NSURL fileURLWithPath:[self filePath]];
}

@ -48,7 +48,7 @@ dispatch_queue_t attachmentsQueue() {
for (PushMessageContentAttachmentPointer *pointer in attachmentsToRetrieve) {
TSAttachmentPointer *attachmentPointer = (content.group != nil && (content.group.type == PushMessageContentGroupContextTypeUpdate)) ? [[TSAttachmentPointer alloc] initWithIdentifier:pointer.id key:pointer.key contentType:pointer.contentType relay:message.relay avatarOfGroupId:content.group.id] : [[TSAttachmentPointer alloc] initWithIdentifier:pointer.id key:pointer.key contentType:pointer.contentType relay:message.relay];
if ([attachmentPointer.contentType hasPrefix:@"image/"]||[attachmentPointer.contentType hasPrefix:@"video/"]) {
if ([attachmentPointer.contentType hasPrefix:@"image/"]||[attachmentPointer.contentType hasPrefix:@"video/"] || [attachmentPointer.contentType hasPrefix:@"audio/"]) {
[attachmentPointer saveWithTransaction:transaction];
dispatch_async(attachmentsQueue(), ^{

@ -85,6 +85,7 @@ typedef enum : NSUInteger {
@property (nonatomic, retain) JSQMessagesBubbleImage *outgoingBubbleImageData;
@property (nonatomic, retain) JSQMessagesBubbleImage *incomingBubbleImageData;
@property (nonatomic, retain) JSQMessagesBubbleImage *outgoingMessageFailedImageData;
@property (nonatomic, strong) NSTimer *audioPlayerPoller;
@property (nonatomic, retain) NSTimer *readTimer;
@ -134,6 +135,8 @@ typedef enum : NSUInteger {
[super viewDidLoad];
[self.navigationController.navigationBar setTranslucent:NO];
[super viewDidLoad];
[self markAllMessagesAsRead];
[self initializeBubbles];
@ -299,7 +302,6 @@ typedef enum : NSUInteger {
self.outgoingBubbleImageData = [bubbleFactory outgoingMessagesBubbleImageWithColor:[UIColor ows_materialBlueColor]];
self.incomingBubbleImageData = [bubbleFactory incomingMessagesBubbleImageWithColor:[UIColor jsq_messageBubbleLightGrayColor]];
self.outgoingMessageFailedImageData = [bubbleFactory outgoingMessageFailedBubbleImageWithColor:[UIColor ows_fadedBlueColor]];
}
-(void)initializeCollectionViewLayout
@ -653,8 +655,8 @@ typedef enum : NSUInteger {
TSAttachmentStream *attStream = (TSAttachmentStream*)attachment;
NSFileManager *fileManager = [NSFileManager defaultManager];
if([messageMedia isVideo]) {
if ([fileManager fileExistsAtPath:[attStream.videoURL path]]) {
_videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:attStream.videoURL];
if ([fileManager fileExistsAtPath:[attStream.mediaURL path]]) {
_videoPlayer = [[MPMoviePlayerController alloc] initWithContentURL:attStream.mediaURL];
[_videoPlayer prepareToPlay];
[[NSNotificationCenter defaultCenter] addObserver:self
@ -667,15 +669,60 @@ typedef enum : NSUInteger {
[self.view addSubview: _videoPlayer.view];
[_videoPlayer setFullscreen:YES animated:YES];
}
} else if([messageMedia isAudio]){
if (messageMedia.isAudioPlaying) {
// if you had started playing an audio msg and now you're tapping it to pause
messageMedia.isAudioPlaying = NO;
[_audioPlayer pause];
messageMedia.isPaused = YES;
[_audioPlayerPoller invalidate];
double current = [_audioPlayer currentTime]/[_audioPlayer duration];
[messageMedia setAudioProgressFromFloat:(float)current];
[messageMedia setAudioIconToPlay];
} else {
BOOL isResuming = NO;
[_audioPlayerPoller invalidate];
// loop through all the other bubbles and set their isPlaying to false
NSInteger num_bubbles = [self collectionView:collectionView numberOfItemsInSection:0];
for (NSInteger i=0; i<num_bubbles; i++) {
NSIndexPath *index_path = [NSIndexPath indexPathForRow:i inSection:0];
TSMessageAdapter *msgAdapter = [collectionView.dataSource collectionView:collectionView messageDataForItemAtIndexPath:index_path];
if (msgAdapter.messageType == TSIncomingMessageAdapter && msgAdapter.isMediaMessage) {
TSVideoAttachmentAdapter* msgMedia = (TSVideoAttachmentAdapter*)[msgAdapter media];
if ([msgMedia isAudio]) {
if (msgMedia == messageMedia && messageMedia.isPaused) {
isResuming = YES;
} else {
msgMedia.isAudioPlaying = NO;
msgMedia.isPaused = NO;
[msgMedia setAudioIconToPlay];
[msgMedia setAudioProgressFromFloat:0];
}
}
else if([messageMedia isAudio]){
DDLogDebug(@"audio location is %@",attStream.videoURL);
}
}
if (isResuming) {
// if you had paused an audio msg and now you're tapping to resume
[_audioPlayer prepareToPlay];
[_audioPlayer play];
[messageMedia setAudioIconToPause];
messageMedia.isAudioPlaying = YES;
messageMedia.isPaused = NO;
_audioPlayerPoller = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(audioPlayerUpdated:) userInfo:@{@"adapter": messageMedia} repeats:YES];
} else {
// if you are tapping an audio msg for the first time to play
messageMedia.isAudioPlaying = YES;
NSError *error;
_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:attStream.videoURL error:&error];
DDLogDebug(@"audio debug is %@",error);
_audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:attStream.mediaURL error:&error];
[_audioPlayer prepareToPlay];
[_audioPlayer play];
[messageMedia setAudioIconToPause];
_audioPlayer.delegate = self;
_audioPlayerPoller = [NSTimer scheduledTimerWithTimeInterval:.01 target:self selector:@selector(audioPlayerUpdated:) userInfo:@{@"adapter": messageMedia} repeats:YES];
}
}
}
}
}
@ -694,7 +741,6 @@ typedef enum : NSUInteger {
}
}
-(NSURL*) changeFile:(NSURL*)originalFile toHaveExtension:(NSString*)extension {
NSFileManager *fileManager = [NSFileManager defaultManager];
NSString* newPath = [[originalFile path] stringByAppendingPathExtension:extension];
@ -1233,6 +1279,71 @@ typedef enum : NSUInteger {
#pragma mark group action view
#pragma mark - Audio
-(void)recordAudio {
// Define the recorder setting
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
[NSString stringWithFormat:@"%lld.m4a",[NSDate ows_millisecondTimeStamp]],
nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
// Setup audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
// Initiate and prepare the recorder
_audioRecorder = [[AVAudioRecorder alloc] initWithURL:outputFileURL settings:recordSetting error:NULL];
_audioRecorder.delegate = self;
_audioRecorder.meteringEnabled = YES;
[_audioRecorder prepareToRecord];
}
- (void)audioPlayerUpdated:(NSTimer*)timer {
NSDictionary *dict = [timer userInfo];
TSVideoAttachmentAdapter *messageMedia = dict[@"adapter"];
double current = [_audioPlayer currentTime]/[_audioPlayer duration];
[messageMedia setAudioProgressFromFloat:(float)current];
NSTimeInterval duration = ([_audioPlayer duration] - [_audioPlayer currentTime]);
[messageMedia setDurationOfAudio:duration];
}
- (void) audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag{
// stop audio polling
[_audioPlayerPoller invalidate];
// reset all audio bars to 0
JSQMessagesCollectionView *collectionView = self.collectionView;
NSInteger num_bubbles = [self collectionView:collectionView numberOfItemsInSection:0];
for (NSInteger i=0; i<num_bubbles; i++) {
NSIndexPath *index_path = [NSIndexPath indexPathForRow:i inSection:0];
TSMessageAdapter *msgAdapter = [collectionView.dataSource collectionView:collectionView messageDataForItemAtIndexPath:index_path];
if (msgAdapter.messageType == TSIncomingMessageAdapter && msgAdapter.isMediaMessage) {
TSVideoAttachmentAdapter* msgMedia = (TSVideoAttachmentAdapter*)[msgAdapter media];
if ([msgMedia isAudio]) {
[msgMedia setAudioProgressFromFloat:0];
[msgMedia setAudioIconToPlay];
[msgMedia removeDurationLabel];
}
}
}
}
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder
successfully:(BOOL)flag {
if(flag) {
[self sendMessageAttachment:[NSData dataWithContentsOfURL:recorder.url] ofType:@"audio/m4a"];
}
}
#pragma mark Accessory View
@ -1274,39 +1385,6 @@ typedef enum : NSUInteger {
}];
}
-(void)recordAudio {
// Define the recorder setting
NSArray *pathComponents = [NSArray arrayWithObjects:
[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject],
[NSString stringWithFormat:@"%lld.m4a",[NSDate ows_millisecondTimeStamp]],
nil];
NSURL *outputFileURL = [NSURL fileURLWithPathComponents:pathComponents];
// Setup audio session
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
NSMutableDictionary *recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
// Initiate and prepare the recorder
_audioRecorder = [[AVAudioRecorder alloc] initWithURL:outputFileURL settings:recordSetting error:NULL];
_audioRecorder.delegate = self;
_audioRecorder.meteringEnabled = YES;
[_audioRecorder prepareToRecord];
}
- (void)audioRecorderDidFinishRecording:(AVAudioRecorder *)recorder
successfully:(BOOL)flag {
if(flag) {
[self sendMessageAttachment:[NSData dataWithContentsOfURL:recorder.url] ofType:@"audio/m4a"];
}
}
- (void)markAllMessagesAsRead {
[self.uiDatabaseConnection readWithBlock:^(YapDatabaseReadTransaction *transaction) {
YapDatabaseViewTransaction *viewTransaction = [transaction ext:TSUnreadDatabaseViewExtensionName];

@ -48,6 +48,7 @@
- (UIView *)mediaView
{
NSLog(@"attachment adapter");
if (self.image == nil) {
return nil;
}

@ -14,13 +14,18 @@
@property NSString *attachmentId;
@property (nonatomic,strong) NSString* contentType;
@property (nonatomic) BOOL isAudioPlaying;
@property (nonatomic) BOOL isPaused;
- (instancetype)initWithAttachment:(TSAttachmentStream*)attachment;
- (BOOL)isImage;
- (BOOL)isAudio;
- (BOOL)isVideo;
- (void)setAudioProgressFromFloat:(float)progress;
- (void)setAudioIconToPlay;
- (void)setAudioIconToPause;
- (void)setDurationOfAudio:(NSTimeInterval)duration;
- (void)removeDurationLabel;
@end

@ -16,25 +16,28 @@
#import "TSNetworkManager.h"
#import "UIColor+OWS.h"
#define AUDIO_BAR_HEIGHT 30;
@interface TSVideoAttachmentAdapter ()
@property UIImage *image;
@property (strong, nonatomic) UIImageView *cachedImageView;
@property (strong, nonatomic) UIImageView *playButton;
@property (strong, nonatomic) CALayer *maskLayer;
@property (strong, nonatomic) FFCircularProgressView *progressView;
@property (strong, nonatomic) TSAttachmentStream *attachment;
@property (strong, nonatomic) NSString *videoURL;
@property (strong, nonatomic) UIProgressView *audioProgress;
@property (strong, nonatomic) UIImageView *playPauseButton;
@property (nonatomic) UILabel *durationLabel;
@end
@implementation TSVideoAttachmentAdapter
- (instancetype)initWithAttachment:(TSAttachmentStream*)attachment{
self = [super initWithFileURL:[attachment videoURL] isReadyToPlay:YES];
self = [super initWithFileURL:[attachment mediaURL] isReadyToPlay:YES];
if (self) {
NSLog(@"attach: %@", attachment);
if (self) {;
_image = attachment.image;
_cachedImageView = nil;
_attachmentId = attachment.uniqueId;
@ -58,16 +61,51 @@
return [_contentType containsString:@"video/"];
}
-(void) setAudioProgressFromFloat:(float)progress {
[_audioProgress setProgress:progress];
}
-(void) setAudioIconToPause {
[_playPauseButton removeFromSuperview];
_playPauseButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"pause_icon"]];
_playPauseButton.frame = CGRectMake(10, 8, 10, 14);
[_audioProgress addSubview:_playPauseButton];
}
-(void) setAudioIconToPlay {
[_playPauseButton removeFromSuperview];
_playPauseButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"play_icon"]];
_playPauseButton.frame = CGRectMake(10, 8, 10, 14);
[_audioProgress addSubview:_playPauseButton];
}
-(void) setDurationOfAudio:(NSTimeInterval)duration {
[_durationLabel removeFromSuperview];
double dur = duration;
int minutes = (int) (dur/60);
int seconds = (int) (dur - minutes*60);
NSString *minutes_str = [NSString stringWithFormat:@"%01d", minutes];
NSString *seconds_str = [NSString stringWithFormat:@"%02d", seconds];
NSString *label_text = [NSString stringWithFormat:@"%@:%@", minutes_str, seconds_str];
CGSize size = [self mediaViewDisplaySize];
_durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(size.width - 40, 0, 50, 30)];
_durationLabel.text = label_text;
_durationLabel.textColor = [UIColor whiteColor];
[_audioProgress addSubview:_durationLabel];
}
-(void) removeDurationLabel {
[_durationLabel removeFromSuperview];
}
#pragma mark - JSQMessageMediaData protocol
- (UIView *)mediaView
{
if (self.image == nil) {
return nil;
}
if (self.cachedImageView == nil) {
CGSize size = [self mediaViewDisplaySize];
if ([self isVideo]) {
if (self.cachedImageView == nil) {
UIImageView *imageView = [[UIImageView alloc] initWithImage:self.image];
imageView.frame = CGRectMake(0.0f, 0.0f, size.width, size.height);
imageView.contentMode = UIViewContentModeScaleAspectFill;
@ -80,7 +118,7 @@
[self.cachedImageView addSubview:_playButton];
_playButton.hidden = YES;
_maskLayer = [CALayer layer];
[_maskLayer setBackgroundColor:[UIColor ows_blackColor].CGColor];
[_maskLayer setBackgroundColor:[UIColor blackColor].CGColor];
[_maskLayer setOpacity:0.4f];
[_maskLayer setFrame:self.cachedImageView.frame];
[self.cachedImageView.layer addSublayer:_maskLayer];
@ -92,19 +130,52 @@
_progressView.hidden = YES;
}
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(attachmentUploadProgress:) name:@"attachmentUploadProgress" object:nil];
}
} else if ([self isAudio]) {
UIImageView *backgroundImage = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, size.width, 30)];
backgroundImage.backgroundColor = [UIColor colorWithRed:189/255.0f green:190/255.0f blue:194/255.0f alpha:1.0f];
_audioProgress = [[UIProgressView alloc] initWithFrame:CGRectMake(0, 0, size.width, 4)];
_playPauseButton = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"play_icon"]];
_playPauseButton.frame = CGRectMake(10, 8, 10, 14);
[_audioProgress addSubview:_playPauseButton];
return _audioProgress;
}
return self.cachedImageView;
}
- (CGSize)mediaViewDisplaySize
{
CGSize mediaDisplaySize;
if ([self isVideo]) {
mediaDisplaySize = [super mediaViewDisplaySize];
} else if ([self isAudio]) {
CGSize size = [super mediaViewDisplaySize];
size.height = AUDIO_BAR_HEIGHT;
mediaDisplaySize = size;
}
return mediaDisplaySize;
}
- (UIView *)mediaPlaceholderView
{
return [self mediaView];
}
- (NSUInteger)hash
{
return [super hash];
}
- (void)attachmentUploadProgress:(NSNotification*)notification {
NSDictionary *userinfo = [notification userInfo];
double progress = [[userinfo objectForKey:@"progress"] doubleValue];
NSString *attachmentID = [userinfo objectForKey:@"attachmentID"];
if ([_attachmentId isEqualToString:attachmentID]) {
NSLog(@"is downloaded: %d", _attachment.isDownloaded);
[_progressView setProgress:progress];
[_progressView setProgress: (float)progress];
if (progress >= 1) {
_maskLayer.hidden = YES;
_progressView.hidden = YES;

Loading…
Cancel
Save