shipingditu

Foundation.framework

UIKit.framework

CoreGraphics.framework

CoreLocation.framework

MapKit.framework

 

AppDelegate.h

AppDelegate.m

 

ViewController.h

ViewController.m

 

NewViewController.h

NewViewController.m

NewViewController.xib

 

 

#import <UIKit/UIKit.h>

#import <AVFoundation/AVFoundation.h>

#import <AVKit/AVKit.h>

 

@interface ViewController : AVPlayerViewController

 

 

@end

 

 

 

 

 

 

#import "ViewController.h"

#import "NewViewController.h"

 

@interface ViewController ()

 

@end

 

@implementation ViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    NSURL *url=[[NSBundle mainBundle] URLForResource:@"movie" withExtension:@"mp4"];

    AVAsset *asset=[AVAsset assetWithURL:url];

    AVPlayerItem *item=[AVPlayerItem playerItemWithAsset:asset];

    self.player=[AVPlayer playerWithPlayerItem:item];

    [self.player seekToTime:kCMTimeZero];

    [self.player play];

}

 

-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

    NewViewController *new=[[NewViewController alloc]init];

    

    [self presentViewController:new animated:YES completion:nil];

}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

@end

 

 

 

 

 

 

 

#import "NewViewController.h"

#import <MapKit/MapKit.h>

#import <CoreLocation/CoreLocation.h>

@interface NewViewController ()<UISearchBarDelegate>

@property (strong, nonatomic) IBOutlet UISearchBar *searchBar;

@property(nonatomic,strong)CLGeocoder *geocoder;//解析器

@property (strong, nonatomic) IBOutlet MKMapView *mapView;

@end

 

@implementation NewViewController

 

- (void)viewDidLoad {

    [super viewDidLoad];

    //设置地图样式

    self.mapView.mapType=MKMapTypeStandard;

    self.mapView.scrollEnabled=YES;

    self.mapView.zoomEnabled=YES;

    self.mapView.rotateEnabled=YES;

    self.mapView.showsUserLocation=YES;

    

    //设置搜索条

    self.searchBar.delegate=self;

    self.searchBar.text=@"北京动物园";

    

    //设置解析器

    self.geocoder=[[CLGeocoder alloc]init];

}

//设置搜索按钮

- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar{

    //显示取消按钮

    self.searchBar.showsCancelButton=YES;

    for (id cc in [searchBar.subviews[0] subviews]) {

        if ([cc isKindOfClass:[UIButton class]]) {

            UIButton *button=(UIButton *)cc;

            [button setTitle:@"搜索" forState:UIControlStateNormal];

        }

    }

}

- (void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{

    [self dosearch:searchBar];

}

- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar{

    [self dosearch:searchBar];

}

 

//点击搜索按钮

-(void)dosearch:(UISearchBar *)searchBar{

    [self.searchBar resignFirstResponder];

    

    [self locateAt:self.searchBar.text];

}

 

//将经纬度转换为字符串

-(void)locateAt:(NSString *)addressName{

    [self.geocoder geocodeAddressString:addressName completionHandler:^(NSArray<CLPlacemark *> * _Nullable placemarks, NSError * _Nullable error) {

        

        if (placemarks.count>0 && error==nil) {

            CLPlacemark *placemark=[placemarks firstObject];

            //设置范围

            MKCoordinateSpan span;

            span.longitudeDelta=0.01;

            span.latitudeDelta=0.01;

            

            MKCoordinateRegion region={placemark.location.coordinate,span};

            //设置地图中心为搜索到的位置

            [self.mapView setRegion:region];

            

            //设置锚点

            MKPointAnnotation *annotation=[[MKPointAnnotation alloc]init];

            //设置锚点的坐标

            annotation.coordinate=placemark.location.coordinate;

            //设置标题AND副标题

            annotation.title=placemark.name;

            annotation.subtitle=[NSString stringWithFormat:@"%@-%@-%@-%@",placemark.country,placemark.administrativeArea,placemark.locality,placemark.subLocality];

            //添加到地图上

            [self.mapView addAnnotation:annotation];

            //指定选中位置

            [self.mapView selectAnnotation:annotation animated:YES];

        }else{

            NSLog(@"没有搜索到");

        }

    }];

}

//-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{

//    [self dismissViewControllerAnimated:YES completion:nil];

//}

 

- (void)didReceiveMemoryWarning {

    [super didReceiveMemoryWarning];

    // Dispose of any resources that can be recreated.

}

 

/*

#pragma mark - Navigation

 

// In a storyboard-based application, you will often want to do a little preparation before navigation

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    // Get the new view controller using [segue destinationViewController].

    // Pass the selected object to the new view controller.

}

*/

 

@end

 

 

 

 

 

 

 

 

Data.h

Data.m

MusicPlayerView.h

MusicPlayerView.m

AppDelegate.h

AppDelegate.m

OneViewController.h

OneViewController..m

MusicPlayerViewController.h

​MusicPlayerViewController.m

TwoViewController.h

TwoViewController.m

ThreeViewController.h

ThreeViewController.m

FourViewController.h

FourViewController.m

 

 

 

Data.h

#import <Foundation/Foundation.h>

 

@interface Data : NSObject<NSCoding>

 

@property(nonatomic,strong)NSString *name;

@property(nonatomic,strong)NSString *singer;

//@property(nonatomic,strong)NSString *albumName;

//@property(nonatomic,strong)NSString *albumImage;

//@property(nonatomic,strong)NSString *url;

//@property(nonatomic,strong)NSString *lrc;

 

 

@end

Data.m

 

 

 

MusicPlayerView.h

#import <UIKit/UIKit.h>

 

@interface MusicPlayerView : UIView

 

 

@property(strong,nonatomic)UIScrollView *scrollView;//滚动视图

@property(strong,nonatomic)UIPageControl *pageCtrl;//页控器

@property(strong,nonatomic)UIView *playControlView;//下部控制播放的视图(不跟着滚动)

@property(strong,nonatomic)UISlider *slider;//控制音乐播放

@property(strong,nonatomic)UIButton *mvBtn;//播放MV

@property(strong,nonatomic)UILabel *nameLabel;//显示歌手姓名

@property(strong,nonatomic)UILabel *songLabel;//显示歌曲和专辑

@property(strong,nonatomic)UIButton *downBtn;//下载按钮

@property(strong,nonatomic)UIButton *likeBtn;//喜欢按钮

@property(strong,nonatomic)UIButton *playBtn;//播放按钮

@property(strong,nonatomic)UIButton *randomBtn;//随机播放按钮

@property(strong,nonatomic)UIButton *backBtn;//上一首按钮

@property(strong,nonatomic)UIButton *nextBtn;//下一首按钮

@property(strong,nonatomic)UIButton *shareBtn;//分享按钮

 

// 当前播放时间的显示标签

@property(nonatomic,strong)UILabel *curtimeLabel;

// 歌曲持续时间的标签

@property(nonatomic,strong)UILabel *durationLabel;

 

 

 

@end

 

MusicPlayerView.m

#import "MusicPlayerView.h"

 

 

@interface MusicPlayerView ()<UIScrollViewDelegate>

 

@end

 

 

@implementation MusicPlayerView

 

- (UIButton *)mvBtn{

    if (_mvBtn == nil) {

        _mvBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _mvBtn.frame = CGRectMake(280, 10, 35, 15);

        [_mvBtn setImage:[UIImage imageNamed:@"channel_friend_play"] forState:UIControlStateNormal];

    }

    return _mvBtn;

}

- (UIPageControl *)pageCtrl{

    if (_pageCtrl == nil) {

        _pageCtrl = [[UIPageControl alloc] init];

        _pageCtrl.numberOfPages = 3;

        _pageCtrl.frame = CGRectMake(140, 40, 40, 20);

        [_pageCtrl addTarget:self action:@selector(pageCtlDidHandle:) forControlEvents:UIControlEventValueChanged];

    }

    return _pageCtrl;

}

- (UISlider *)slider{

    if (_slider == nil) {

        _slider = [[UISlider alloc] initWithFrame:CGRectMake(0, 60, 320, 2)];

        _slider.tintColor = [UIColor whiteColor];

        [_slider setThumbImage:[UIImage imageNamed:@"channel_friend_pause"] forState:UIControlStateNormal];

    }

    return _slider;

}

- (UIScrollView *)scrollView{

    if (_scrollView == nil) {

        _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, self.frame.size.height - 154)];

        _scrollView.contentSize = CGSizeMake(_scrollView.frame.size.width * 3, 0);

        _scrollView.bounces= YES;

        _scrollView.showsHorizontalScrollIndicator = NO;

        _scrollView.showsVerticalScrollIndicator = NO;

        _scrollView.pagingEnabled = YES;

        for (int i = 0; i < 3; i ++) {

            CGRect frame = _scrollView.frame;

            

            if (i == 1) {

                UIImageView *img = [[UIImageView alloc] initWithFrame:CGRectMake(frame.size.width * i, 0, frame.size.width, frame.size.height)];

                img.image = [UIImage imageNamed:@"zhouwen.jpg"];

                img.backgroundColor = [UIColor grayColor];

                [_scrollView addSubview:img];

            }

            else

            {

                UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(frame.size.width * i, 0, frame.size.width, frame.size.height) style:UITableViewStylePlain];

                tableView.tag = 4000 + i;

                [_scrollView addSubview:tableView];

            }

            

            _scrollView.delegate = self;

        }

    }

    return _scrollView;

}

- (UILabel *)nameLabel{

    if (_nameLabel == nil) {

        _nameLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 8, 100, 20)];

        _nameLabel.text = @"姓名";

        _nameLabel.font = [UIFont boldSystemFontOfSize:18];

        _nameLabel.textColor = [UIColor whiteColor];

    }

    return  _nameLabel;

}

- (UILabel *)songLabel{

    if (_songLabel == nil) {

        _songLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 28, 120, 20)];

        _songLabel.text = @"歌曲名";

        _songLabel.font = [UIFont systemFontOfSize:11];

        _songLabel.textColor = [UIColor colorWithWhite:0.8 alpha:1];

    }

    return _songLabel;

}

- (UIButton *)downBtn{

    if (_downBtn == nil) {

        _downBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _downBtn.frame = CGRectMake(215, 10, 40, 40);

        [_downBtn setImage:[UIImage imageNamed:@"cell_download_all_h"] forState:UIControlStateNormal];

    }

    return _downBtn;

}

- (UIButton *)likeBtn{

    if (_likeBtn == nil) {

        _likeBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _likeBtn.frame = CGRectMake(265, 10, 40, 40);

        [_likeBtn setImage:[UIImage imageNamed:@"cell_like_in_my_music_pressed"] forState:UIControlStateNormal];

        [_likeBtn setImage:[UIImage imageNamed:@"cell_like_in_my_music"] forState:UIControlStateSelected];

    }

    return _likeBtn;

}

- (UIButton *)playBtn{

    if (_playBtn == nil) {

        _playBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _playBtn.frame = CGRectMake(125, 70, 70, 70);

        [_playBtn setImage:[UIImage imageNamed:@"channel_friend_play"] forState:UIControlStateNormal];

        [_playBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateSelected];

    }

    return _playBtn;

}

- (UIButton *)randomBtn{

    if (_randomBtn == nil) {

        _randomBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _randomBtn.frame = CGRectMake(15, 87, 40, 40);

        [_randomBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

    }

    return _randomBtn;

}

- (UIButton *)backBtn{

    if (_backBtn == nil) {

        _backBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _backBtn.frame = CGRectMake(65, 85, 40, 40);

        [_backBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

    }

    return _backBtn;

}

- (UIButton *)nextBtn{

    if (_nextBtn == nil) {

        _nextBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _nextBtn.frame = CGRectMake(215, 85, 40, 40);

        [_nextBtn setImage:[UIImage imageNamed:@"forme_btn_play"] forState:UIControlStateNormal];

    }

    return _nextBtn;

}

- (UIButton *)shareBtn{

    if (_shareBtn == nil) {

        _shareBtn = [UIButton buttonWithType:UIButtonTypeCustom];

        _shareBtn.frame = CGRectMake(265, 82, 50, 50);

        [_shareBtn setImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];

    }

    return _shareBtn;

}

- (UIView *)playControlView{

    if (_playControlView == nil) {

        _playControlView = [[UIView alloc] initWithFrame:CGRectMake(0, 414, 320, 154)];

        _playControlView.backgroundColor = [UIColor grayColor];

        [_playControlView addSubview:self.nameLabel];

        [_playControlView addSubview:self.songLabel];

        [_playControlView addSubview:self.downBtn];

        [_playControlView addSubview:self.likeBtn];

        [_playControlView addSubview:self.pageCtrl];

        [_playControlView addSubview:self.slider];

        [_playControlView addSubview:self.playBtn];

        [_playControlView addSubview:self.randomBtn];

        [_playControlView addSubview:self.backBtn];

        [_playControlView addSubview:self.nextBtn];

        [_playControlView addSubview:self.shareBtn];

        [_playControlView addSubview:self.curtimeLabel];

        [_playControlView addSubview:self.durationLabel];

    }

    return _playControlView;

}

// 当前播放时间标签

-(UILabel *)curtimeLabel

{

    if (!_curtimeLabel) {

        _curtimeLabel = [[UILabel alloc] initWithFrame:CGRectMake(10, 75, 40, 15)];

        _curtimeLabel.font = [UIFont systemFontOfSize:10];

        _curtimeLabel.textColor = [UIColor whiteColor];

    }

    return _curtimeLabel;

}

// 音乐持续时间标签

-(UILabel *)durationLabel

{

    if (!_durationLabel) {

        _durationLabel = [[UILabel alloc] initWithFrame:CGRectMake(285, 75, 30, 15)];

        _durationLabel.font = [UIFont systemFontOfSize:10];

        _durationLabel.textColor = [UIColor whiteColor];

    }

    return _durationLabel;

}

#pragma mark -  控件触发事件

-(void)pageCtlDidHandle:(UIPageControl *)sender

{

    

    // 获得当前分页

    NSInteger curPage = sender.currentPage;

    

    

    CGRect frame = self.scrollView.frame;

    // 设置滚动视图需要滚到的区域

    CGRect toRect = CGRectMake(frame.size.width  * curPage, frame.origin.y, frame.size.width, frame.size.height);

    // 改变滚动视图

    [self.scrollView scrollRectToVisible:toRect animated:YES];

    

}

 

#pragma mark - UIScrollViewDelegate

-(void)scrollViewDidScroll:(UIScrollView *)scrollView

{

    // 获得当前分页

    NSInteger curPage = fabs(scrollView.contentOffset.x / 320);

    self.pageCtrl.currentPage = curPage;

}

#pragma mark - ViewLoad

- (id)initWithFrame:(CGRect)frame

{

    self = [super initWithFrame:frame];

    if (self) {

        [self addSubview:self.scrollView];

        [self addSubview:self.playControlView];

        

        self.pageCtrl.currentPage = 1;

        self.scrollView.contentOffset = CGPointMake(320, 0);

        

    }

    return self;

}

 

 

@end

 

 

 

 

 

 

 

 

AppDelegate.h

#import <UIKit/UIKit.h>

 

@interface AppDelegate : UIResponder <UIApplicationDelegate>

 

@property (strong, nonatomic) UIWindow *window;

 

 

@end

AppDelegate.m

 

#import "AppDelegate.h"

#import "OneViewController.h"

#import "TwoViewController.h"

#import "ThreeViewController.h"

#import "FourViewController.h"

 

@interface AppDelegate ()

 

@end

 

@implementation AppDelegate

 

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    //底部标签栏

    OneViewController *oneVC =[[OneViewController alloc]init];

    UINavigationController *nav1 =[[UINavigationController alloc]initWithRootViewController:oneVC];

    UITabBarItem *item1 =[[UITabBarItem alloc]initWithTitle:@"我的音乐" image:[UIImage imageNamed:@"mymusic"] selectedImage:[UIImage imageNamed:@"mymusic_click"]];

    nav1.tabBarItem =item1;

    

    TwoViewController *TwoVC =[[TwoViewController alloc]init];

    UINavigationController *nav2 =[[UINavigationController alloc]initWithRootViewController:TwoVC];

    UITabBarItem *item2 =[[UITabBarItem alloc]initWithTitle:@"音乐馆" image:[UIImage imageNamed:@"yinyueguan"] selectedImage:[UIImage imageNamed:@"yinyueguan_click"]];

    nav2.tabBarItem =item2;

    

    ThreeViewController *ThreeVC =[[ThreeViewController alloc]init];

    UINavigationController *nav3 =[[UINavigationController alloc]initWithRootViewController:ThreeVC];

    UITabBarItem *item3 =[[UITabBarItem alloc]initWithTitle:@"发现" image:[UIImage imageNamed:@"find"] selectedImage:[UIImage imageNamed:@"find_click"]];

    nav3.tabBarItem =item3;

    

    FourViewController *fourVC =[[FourViewController alloc]init];

    UINavigationController *nav4 =[[UINavigationController alloc]initWithRootViewController:fourVC];

    UITabBarItem *item4 =[[UITabBarItem alloc]initWithTitle:@"更多" image:[UIImage imageNamed:@"more@2x副本"] selectedImage:[UIImage imageNamed:@"more_click"]];

    nav4.tabBarItem =item4;

    

    

    UITabBarController *tabBar =[[UITabBarController alloc]init];

    tabBar.viewControllers=@[nav1,nav2,nav3,nav4];

    self.window.rootViewController=tabBar;

    

    return YES;

}

 

 

@end

 

 

 

 

 

 

 

 

 

OneViewController.h

#import <UIKit/UIKit.h>

 

@interface OneViewController : UIViewController

 

@end

OneViewController..m

 

#import "OneViewController.h"

#import "MusicPlayerViewController.h"

 

@interface OneViewController ()<UITableViewDelegate,UITableViewDataSource>

{

    UITableView *table;

    UISearchBar *search;

    UISearchDisplayController *dis;

    NSArray *titleArr;

    NSArray *imgArr;

    

}

@end

 

@implementation OneViewController

 

 

-(void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationItem.title = @"我的音乐";

    UIBarButtonItem *rightItem =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"13"] style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    self.navigationItem.rightBarButtonItem =rightItem;

    self.navigationController.navigationBar.tintColor =[UIColor greenColor];

    

    table =[[UITableView alloc]initWithFrame:self.view.frame style:UITableViewStyleGrouped];

    table.dataSource=self;

    table.delegate=self;

    [self.view addSubview:table];

    

    search =[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 40)];

    search.placeholder =@"搜索";

    dis =[[UISearchDisplayController alloc]initWithSearchBar:search contentsController:self];

    dis.searchResultsDataSource=self;

    dis.searchResultsDelegate=self;

    table.tableHeaderView=search;

    

    titleArr = @[@"全部歌曲",@"下载歌曲",@"最近播放"];

 

}

-(void)click

{

    MusicPlayerViewController *mp =[[MusicPlayerViewController alloc]init];

    [self.navigationController pushViewController:mp animated:YES];

    

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    return 3;

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    if (section==0) {

        return 1;

    }else if (section==1){

        return 3;

    }else

    {

        return 2;

    }

}

 

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

    UITableViewCell *cell;

    if(indexPath.section == 0){

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:nil];

    }else{

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];

    }

    if (indexPath.section == 0) {

        cell.imageView.image = [UIImage imageNamed:@"dl"];

        cell.textLabel.text = @"未登录";

        cell.textLabel.font = [UIFont systemFontOfSize:20];

        cell.detailTextLabel.text = @"登录后和朋友们分享";

        cell.detailTextLabel.font = [UIFont systemFontOfSize:15];

        cell.detailTextLabel.textColor = [UIColor lightGrayColor];

        

        UIButton *b = [UIButton buttonWithType:UIButtonTypeCustom];

        b.frame = CGRectMake(300, 30, 60, 30);

        [b setTitle:@"登录" forState:UIControlStateNormal];

        [b setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];

        [b addTarget:self action:@selector(clickBtn) forControlEvents:UIControlEventTouchUpInside];

        b.layer.borderWidth = 1;

        b.layer.borderColor = [UIColor greenColor].CGColor;

        b.layer.cornerRadius = 8;

        [cell addSubview:b];

    }else if(indexPath.section == 1){

        cell.imageView.image = [UIImage imageNamed:imgArr[indexPath.row]];

        cell.textLabel.text = titleArr[indexPath.row];

        cell.detailTextLabel.text = @"100首";

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    }else{

        if (indexPath.row == 0) {

            cell.textLabel.text = @"我的歌单";

            cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        }else{

            cell = [[UITableViewCell alloc]init];

            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 40, 300, 40)];

            label.text = @"                ,点击红心收藏喜欢的歌曲,\n同时同步到你的所有设备";

            label.textAlignment = NSTextAlignmentCenter;

            label.font = [UIFont systemFontOfSize:15];

            //lable支持行数 如果-1 自动匹配行。

            label.numberOfLines = -1;

            [cell addSubview:label];

            

            UIButton *b = [UIButton buttonWithType:UIButtonTypeRoundedRect];

            b.frame = CGRectMake(10, -5, 80, 30);

            [b setTitle:@"登录账户" forState:UIControlStateNormal];

            [b setTitleColor:[UIColor greenColor] forState:UIControlStateNormal];

            [b addTarget:self action:@selector(clickLoad) forControlEvents:UIControlEventTouchUpInside];

            b.layer.cornerRadius = 4;

            [label addSubview:b];

        }

    }

    return cell;

}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

{

    if (indexPath.section == 0) {

        return 100;

    }else if(indexPath.section == 1){

        return 50;

    }else{

        if (indexPath.row == 0) {

            return 50;

        }else{

            return 120;

        }

    }

}

-(void)clickBtn{

    

}

-(void)clickLoad{

    

}

 

@end

 


 

 

MusicPlayerViewController.h

#import <UIKit/UIKit.h>

#import "Data.h"

 

@interface MusicPlayerViewController : UIViewController

 

@property(nonatomic,strong)Data *music;

 

@end

MusicPlayerViewController.m

#import "MusicPlayerViewController.h"

#import <AVFoundation/AVFoundation.h>

#import "MusicPlayerView.h"

 

@interface MusicPlayerViewController ()<UITableViewDelegate,UITableViewDataSource,AVAudioPlayerDelegate>

{

    

}

//模型

@property(nonatomic,strong)Data *MusicModel;

@property(nonatomic,strong)MusicPlayerView *myPlayerView;

//音乐播放器对象

@property(nonatomic,strong)AVAudioPlayer *myAudio;

//定时器

@property(nonatomic,strong)NSTimer *myTimer;

 

@end

 

@implementation MusicPlayerViewController

 

-(Data *)MusicModel{

    if (!_MusicModel) {

        _MusicModel = [[Data alloc]init];

    }

    return _MusicModel;

}

-(MusicPlayerView *)myPlayerView{

    if (!_myPlayerView) {

        _myPlayerView = [[MusicPlayerView alloc]initWithFrame:[UIScreen mainScreen].bounds];

    }

    return _myPlayerView;

}

 

-(void)viewDidLoad

{

    [super viewDidLoad];

    

    self.view=self.myPlayerView;

    [self.myPlayerView.playBtn addTarget:self action:@selector(playBtnDidHandle) forControlEvents:UIControlEventTouchUpInside];

    [self.myPlayerView.slider addTarget:self action:@selector(sliderDidHandle) forControlEvents:UIControlEventValueChanged];

    

    

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

    return 1;

}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section

{

    return nil;

}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cellid = @"cell";

    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellid];

    if (!cell) {

        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellid];

    }

    

    return cell;

}

 

-(void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    

    self.navigationController.navigationBarHidden = NO;

    self.navigationController.tabBarController.tabBar.hidden = YES;

    self.myPlayerView.nameLabel.text = self.music.name;

    self.myPlayerView.songLabel.text = self.music.singer;

 

    self.navigationItem.title = self.music.name;

 

    NSString *string = [[NSBundle mainBundle] pathForResource:@"天高地厚" ofType:@"mp3"];

    NSURL *url = [NSURL fileURLWithPath:string];

    //初始化音频类 并且添加播放文件

    _myAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];

 

}

-(void)playBtnDidHandle

{

    [_myAudio play];

}

-(void)sliderDidHandle

{

    

}

 

@end

 

TwoViewController.h

#import <UIKit/UIKit.h>

 

@interface TwoViewController : UIViewController

 

@end

TwoViewController.m

#import "TwoViewController.h"

 

 

@interface TwoViewController ()

{

    

}

@end

 

 

@implementation TwoViewController

 

-(void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationItem.title = @"音乐馆";

 

}

 

 

@end

 

 

 

ThreeViewController.h

#import <UIKit/UIKit.h>

 

@interface ThreeViewController : UIViewController

 

@end

 

ThreeViewController.m

#import "ThreeViewController.h"

 

 

@interface ThreeViewController ()

{

    

}

 

@end

 

 

@implementation ThreeViewController

 

-(void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationItem.title = @"发现";

 

}

 

 

@end

 

 

 

 

 

 

FourViewController.h

#import <UIKit/UIKit.h>

 

@interface FourViewController : UIViewController

 

@end

 

FourViewController.m

#import "FourViewController.h"

 

@interface FourViewController ()

{

    

}

 

@end

 

 

@implementation FourViewController

 

 

-(void)viewDidLoad

{

    [super viewDidLoad];

    self.view.backgroundColor = [UIColor whiteColor];

    self.navigationItem.title = @"更多";

    //导航按钮

    UIBarButtonItem *leftItem =[[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"play"] style:UIBarButtonItemStylePlain target:self action:@selector(click)];

    self.navigationItem.leftBarButtonItem=leftItem;

    self.navigationController.navigationBar.tintColor =[UIColor greenColor];

    

    

}

-(void)click

{

    

}

 

@end

 

 

 

 

 

转载于:https://my.oschina.net/zhouwenhuan/blog/652789

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值