首页 > 移动平台 > 详细

AudioStreamer使用之快速点击下/上一首按钮,音频会重复的问题解决。

时间:2015-10-28 01:29:40      阅读:211      评论:0      收藏:0      [点我收藏+]

针对此问题,我的做法是在AudioStreamer.h文件新加入一个属性

@property (nonatomic,strong) NSURL *musicUrl;

和一个单例方法:

+(id)sharedStreamer;

同时在AudioStreamer.m文件中实现单例方法和musicURL的set方法

+(id)sharedStreamer{

    static AudioStreamer *streamer = nil;

    static dispatch_once_t tocken;

    dispatch_once(&tocken, ^{

        streamer = [[AudioStreamer alloc] init];

    });

    return streamer;

}

 

-(void)setMusicUrl:(NSURL *)musicUrl{

    url = musicUrl;

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(handleInterruptionChangeToState:) name:ASAudioSessionInterruptionOccuredNotification object:nil];

}

 

这样后在创建streamer对象的时候变可以像下面那样做:

streamer = [AudioStreamer sharedStreamer];

[streamer stop];

streamer.musicUrl = url;

[streamer start];

 

那么问题解决。。晚安!

AudioStreamer使用之快速点击下/上一首按钮,音频会重复的问题解决。

原文:http://www.cnblogs.com/buakaw/p/ios.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!