iOS Development Outreach-Audio processing (music player 2)

Source: Internet
Author: User

iOS Development Outreach-Audio processing (music player 2)

Description: This article mainly introduces the construction of the music playing interface.

First, jump

1. Method selection to jump to the music playback interface (1) Use modal jumps (also divided into manual and Automatic) (2) Use Xib and set jump 2. Two methods of analysis can use the modal method, add a controller, let this controller and music play Controller class to associate, off line,  Set the identifier and execute segue in the cell's click event.      Step Description: (1) Drag a new controller into the storyboard, then set and associate with the playing controller class. (2) Set manual jump (3) Set Segue identifier (3) Jump code processingThe following reasons are not recommended for the use of modal modes:If you want to jump back to the music list screen after selecting a music to jump to the playback interface, the most common practice is to add a button to the music playback controller. When clicked, destroy this controller (dismissed).    However, the controller destroys the music that is playing and then it is gone. And because the layout of the playback interface controller is fixed, the method chosen here is created using Xib.  3. Select the method to create a new xib, corresponding to the music playback controller. The structure of the xib is as follows:Details: The controller only needs to be created once, so lazy loading is recommended, but the player is set as a singleton
1 //2 //YYMUSICSVIEWCONTROLLER.M3 //4 5 #import "YYMusicsViewController.h"6 #import "YYMusicModel.h"7 #import "MJExtension.h"8 #import "YYMusicCell.h"9 #import "YYPlayingViewController.h"Ten  One @interfaceYymusicsviewcontroller () A@property (nonatomic,strong) Nsarray *musics;  @property (nonatomic,strong) Yyplayingviewcontroller *Playingviewcontroller;  - @end the  - @implementationYymusicsviewcontroller - #pragmamark-Lazy Loading --(Nsarray *) musics + { -     if(_musics==Nil) { +_musics=[yymusicmodel Objectarraywithfilename:@"musics.plist"]; A     } at     return_musics; - }  -(Yyplayingviewcontroller *) playingviewcontroller  (_playingviewcontroller==nil) { _playingviewcontroller=[[Yyplayingviewcontroll Er alloc]init];  ()-return  _playingviewcontroller; +}            
Internal details of the 4.xib: (1) Constraints have been implemented for the adaptation of IOS6 and iOS7. (2) Set the music name and the singer's view set to translucent, set the method as follows: set to 30%Note: Do not set the transparency on the properties panel of the control in the storyboard (so that the child controls in this control are the same transparency). Deprecated Practices: (3) button click Glow (4) Setting the view hide can save some performance. (Reference Code) (5) in the process of switching the controller, the Setup window cannot be clicked (this is done to prevent the user from multiple consecutive clicks on the song name will appear the problem). 5. Add: The UIView classification is dragged into the project code to facilitate the calculation of the frame Second, the code involvedProvides a common object method interface YYPlayingViewController.h file in the. h file of the playback controller
1 //   YYPlayingViewController.h23#import <UIKit/UIKit.h>4  5@interface  yyplayingviewcontroller:uiviewcontroller6//  Show controller 7 -(void) show; 8 @end

YYPLAYINGVIEWCONTROLLER.M file

1 //2 //YYPLAYINGVIEWCONTROLLER.M3 //4 5 #import "YYPlayingViewController.h"6 7 @interfaceYyplayingviewcontroller ()8-(ibaction) exit;9 Ten @end One  A @implementationYyplayingviewcontroller - #pragmamark-Public methods --(void) Show the { -     //1. Disable click events for the entire app -UIWindow *window=[uiapplication Sharedapplication].keywindow; -     Window.userinteractionenabled=no; +      -     //2. Add the Playback interface +     //set the view size to cover the entire window ASelf.view.frame=window.bounds; at     //Setting the view display -     Self.view.hidden=no; -     //add view to the window - [window AddSubview:self.view]; -      -     //3. Use animations to show the view inself.view.y=Self.view.height; -[UIView animatewithduration:0.25animations:^{ toself.view.y=0; +} completion:^(BOOL finished) { -         Window.userinteractionenabled=yes; the     }]; * } $ #pragmaButton monitoring method inside the mark-Panax Notoginseng //Back button --(ibaction) exit { the     //1. Disable click events for the entire app +UIWindow *window=[uiapplication Sharedapplication].keywindow; A    Window.userinteractionenabled=no; the      +     //2. Animate hidden View -[UIView animatewithduration:0.25animations:^{ $self.view.y=Window.height; $} completion:^(BOOL finished) { -         Window.userinteractionenabled=yes; -         //setting view shadowing can save some performance the         Self.view.hidden=yes; -     }];Wuyi } the @end

The processing code in the cell's Click event:

1 /**2 * Cell's Click event3  */4-(void) TableView: (UITableView *) TableView Didselectrowatindexpath: (Nsindexpath *) Indexpath5 {6     //uncheck the line that was clicked7 [TableView Deselectrowatindexpath:indexpath animated:yes];8     9     //calling public methods[Self.playingviewcontroller show]; One      A //    //Execute Segue Jump - //[Self performseguewithidentifier:@ "music2playing" sender:nil]; -}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.