-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fisrt Version
- Loading branch information
0 parents
commit a076956
Showing
28 changed files
with
3,080 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
415 changes: 415 additions & 0 deletions
415
LameMp3EncodeDemo/LameMp3EncodeDemo.xcodeproj/project.pbxproj
Large diffs are not rendered by default.
Oops, something went wrong.
7 changes: 7 additions & 0 deletions
7
LameMp3EncodeDemo/LameMp3EncodeDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Binary file added
BIN
+60.5 KB
...codeproj/project.xcworkspace/xcuserdata/andong.xcuserdatad/UserInterfaceState.xcuserstate
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
...p3EncodeDemo.xcodeproj/xcuserdata/andong.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Bucket | ||
type = "1" | ||
version = "2.0"> | ||
</Bucket> |
14 changes: 14 additions & 0 deletions
14
...eMp3EncodeDemo.xcodeproj/xcuserdata/andong.xcuserdatad/xcschemes/xcschememanagement.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>SchemeUserState</key> | ||
<dict> | ||
<key>LameMp3EncodeDemo.xcscheme</key> | ||
<dict> | ||
<key>orderHint</key> | ||
<integer>0</integer> | ||
</dict> | ||
</dict> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// AppDelegate.h | ||
// LameMp3EncodeDemo | ||
// | ||
// Created by AnDong on 2018/2/13. | ||
// Copyright © 2018年 AnDong. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface AppDelegate : UIResponder <UIApplicationDelegate> | ||
|
||
@property (strong, nonatomic) UIWindow *window; | ||
|
||
|
||
@end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// | ||
// AppDelegate.m | ||
// LameMp3EncodeDemo | ||
// | ||
// Created by AnDong on 2018/2/13. | ||
// Copyright © 2018年 AnDong. All rights reserved. | ||
// | ||
|
||
#import "AppDelegate.h" | ||
|
||
@interface AppDelegate () | ||
|
||
@end | ||
|
||
@implementation AppDelegate | ||
|
||
|
||
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { | ||
// Override point for customization after application launch. | ||
return YES; | ||
} | ||
|
||
|
||
- (void)applicationWillResignActive:(UIApplication *)application { | ||
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | ||
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. | ||
} | ||
|
||
|
||
- (void)applicationDidEnterBackground:(UIApplication *)application { | ||
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | ||
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | ||
} | ||
|
||
|
||
- (void)applicationWillEnterForeground:(UIApplication *)application { | ||
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. | ||
} | ||
|
||
|
||
- (void)applicationDidBecomeActive:(UIApplication *)application { | ||
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | ||
} | ||
|
||
|
||
- (void)applicationWillTerminate:(UIApplication *)application { | ||
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | ||
} | ||
|
||
|
||
@end |
93 changes: 93 additions & 0 deletions
93
LameMp3EncodeDemo/LameMp3EncodeDemo/Assets.xcassets/AppIcon.appiconset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "20x20", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "29x29", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "40x40", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "iphone", | ||
"size" : "60x60", | ||
"scale" : "3x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "20x20", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "20x20", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "29x29", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "40x40", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "76x76", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "ipad", | ||
"size" : "83.5x83.5", | ||
"scale" : "2x" | ||
} | ||
], | ||
"info" : { | ||
"version" : 1, | ||
"author" : "xcode" | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
LameMp3EncodeDemo/LameMp3EncodeDemo/AudioPlayViewController.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// | ||
// AudioPlayViewController.h | ||
// LameMp3EncodeDemo | ||
// | ||
// Created by AnDong on 2018/3/15. | ||
// Copyright © 2018年 AnDong. All rights reserved. | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@class Mp3FileModel; | ||
|
||
@interface AudioPlayViewController : UIViewController | ||
|
||
@property (nonatomic,strong)Mp3FileModel *fileModel; | ||
|
||
@end |
117 changes: 117 additions & 0 deletions
117
LameMp3EncodeDemo/LameMp3EncodeDemo/AudioPlayViewController.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
// | ||
// AudioPlayViewController.m | ||
// LameMp3EncodeDemo | ||
// | ||
// Created by AnDong on 2018/3/15. | ||
// Copyright © 2018年 AnDong. All rights reserved. | ||
// | ||
|
||
#import "AudioPlayViewController.h" | ||
#import <AVFoundation/AVFoundation.h> | ||
#import "Mp3FileModel.h" | ||
|
||
@interface AudioPlayViewController ()<AVAudioPlayerDelegate> | ||
@property (weak, nonatomic) IBOutlet UILabel *playTimeLabel; | ||
@property (weak, nonatomic) IBOutlet UIButton *playBtn; | ||
@property (nonatomic,strong) AVAudioPlayer *player; | ||
@property (nonatomic,strong) NSTimer *playStatusTimer; | ||
@end | ||
|
||
@implementation AudioPlayViewController | ||
|
||
|
||
- (void)viewDidLoad { | ||
[super viewDidLoad]; | ||
|
||
self.player = [[AVAudioPlayer alloc]initWithContentsOfURL: | ||
[NSURL URLWithString:self.fileModel.mp3Path] | ||
error:nil]; | ||
self.player.delegate = self; | ||
//开始播放 | ||
[self.player prepareToPlay]; | ||
//播放 | ||
[self.player play]; | ||
|
||
[self startPlayStatusTimer]; | ||
} | ||
|
||
- (void)viewDidDisappear:(BOOL)animated{ | ||
[super viewDidDisappear:animated]; | ||
[self.player stop]; | ||
[self stopPlayStatusTimer]; | ||
} | ||
|
||
- (IBAction)navBack:(UIButton *)sender { | ||
[self dismissViewControllerAnimated:YES completion:^{ | ||
|
||
}]; | ||
} | ||
|
||
- (void)updateTime{ | ||
NSTimeInterval currentTime = self.player.currentTime; | ||
self.playTimeLabel.text = [self getFormatString:currentTime]; | ||
} | ||
|
||
- (NSString *)getFormatString:(NSInteger)totalSeconds { | ||
NSInteger seconds = totalSeconds % 60; | ||
NSInteger minutes = (totalSeconds / 60) % 60; | ||
NSInteger hours = totalSeconds / 3600; | ||
if (hours <= 0) { | ||
return [NSString stringWithFormat:@"%02ld:%02ld",(long)minutes, (long)seconds]; | ||
} | ||
return [NSString stringWithFormat:@"%02ld:%02ld:%02ld",(long)hours, (long)minutes, (long)seconds]; | ||
} | ||
|
||
- (void)startPlayStatusTimer{ | ||
if (!self.playStatusTimer) { | ||
self.playStatusTimer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(updateTime) userInfo:nil repeats:YES]; | ||
[self.playStatusTimer setFireDate:[NSDate distantPast]]; | ||
} | ||
} | ||
|
||
- (void)stopPlayStatusTimer{ | ||
if (self.playStatusTimer) { | ||
[self.playStatusTimer invalidate]; | ||
self.playStatusTimer = nil; | ||
self.playTimeLabel.text = @"00:00"; | ||
} | ||
} | ||
|
||
#pragma mark - AVAudioPlayerDelegate | ||
|
||
- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)flag{ | ||
//播放结束 | ||
[self stopPlayStatusTimer]; | ||
} | ||
|
||
- (void)audioPlayerDecodeErrorDidOccur:(AVAudioPlayer*)player error:(NSError *)error{ | ||
//解码错误 | ||
} | ||
|
||
- (void)audioPlayerBeginInteruption:(AVAudioPlayer*)player{ | ||
//处理中断 | ||
} | ||
|
||
- (void)audioPlayerEndInteruption:(AVAudioPlayer*)player{ | ||
//处理中断结束 | ||
} | ||
|
||
|
||
- (IBAction)playBtnClick:(UIButton *)sender { | ||
//暂停播放 | ||
sender.selected = !sender.selected; | ||
|
||
if (sender.selected) { | ||
//暂停 | ||
[self.player pause]; | ||
[sender setTitle:@"开始播放" forState:UIControlStateNormal]; | ||
} | ||
else{ | ||
//开始播放 | ||
[self.player play]; | ||
[sender setTitle:@"暂停" forState:UIControlStateNormal]; | ||
} | ||
} | ||
|
||
|
||
@end |
Oops, something went wrong.