One of Sina Weibo project technology is playing button click

Source: Internet
Author: User

One.:

implement function: when the "playing" button, switch to the next screen and continue the original song playback progress

Two. Implementation methods and procedures

1. Idea: the first step. When you click on the button event and show it to the next interface, it launches to the singleton view we created (the second interface view was previously created as a singleton)

The second step. When you click on the page to play, if the current play as the fourth song, show is also the fourth, you do not need to play from the beginning, continue to play the current position, if it is the next one will need to play from the beginning (think clearly this logic judgment relationship)

2. Steps :

The first step is to implement the steps:

@interface Musiclisttableviewcontroller ()-(Ibaction) Didclickplayingbarbutton: (Uibarbuttonitem *) sender; @end

// Click the button to push to the second Singleton Object view page -(ibaction) Didclickplayingbarbutton: (Uibarbuttonitem *) sender    {//  Get the Singleton object method    Musicplayerviewcontroller *playvc = [Musicplayerviewcontroller SHAREMUSICPLAYVC];     //show to the next page     [Self.navigationcontroller showviewcontroller:playvc sender:self];}

The second step is to implement the steps:

In the method that the view will appear, make a judgment. History does not put the line label of the song is the same as the current subscript. If the same continues with the current song playback, if it is different, play it again.

1. Declare a property store to play the subscript of the song

@property (nonatomic,assign) Nsinteger currentindex;  // History Store the subscript of the previous (old) music song  used to temporarily save the playing song
    // assign an initial value    _currentindex =-1;

2. Judge the page that will appear on the view

Play music when #pragma mark---View is going to appear-(void) viewwillappear: (BOOL) animated{    [Super Viewwillappear : animated];     // determines whether the song clicked by the button is equal    to the current if (_index = = _currentindex)        {return;    }
[Self prepareforplaying];}

Note: In this judgment there is a problem, if play the first song, subscript index is 0, then _index = _currentindex is also equal, then will not go to start playing that method, resulting in the first one can not play.

Workaround:

-(void) prepareforplaying{
_currentindex is used to temporarily store index play songs as a temporary storage variable = _index ; * Indexpath = [Nsindexpath indexpathforrow:_currentindex insection:0];

One of Sina Weibo project technology is playing button click

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.