Discussion Forums  >  Audio, Video, Playing, Recording

Replies: 17    Views: 133

Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
12/16/12 05:41 PM (11 years ago)

Stream Audio Plugin Question on Continuous Play

Hey Danny, Question, I have a music app that I am updating as we speak with your plugin as the update. My original release used a custom url with quicktime to play the tracks and also had the ability to play the music when silent, mute and locked modes are engaged. I applied the same changes to my updated version but now the music doesn't play via the plugin but does work if i use a custom url with quicklime. Here are the changes that were made to the code. 1. Required Background Modes was added into the target as an array 2. app plays audio was added as its string 3. Appdelegate.m file was edited as such yourAppName_appDelegate.m file....scroll down pretty far in this file to around line 880 just after the array list of .mp3 sound effects you will see this code //setup audio session for background sounds. Allow iPod to continue if it's already playing. [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; [[AVAudioSession sharedInstance] setActive: YES error: nil]; NOW just after that code paste the code below...you should now have audio and video playing regardless of mute switch on side of device...i tested and worked for me. // prevent mute switch from switching off audio from movie player NSError *_error = nil; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &_error]; 4. - Add the following code in the audioplayer.m file //Adds ability for audio to play even in screen lock NSError *setCategoryErr = nil; NSError *activationErr = nil; [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: &setCategoryErr]; [[AVAudioSession sharedInstance] setActive: YES error: &activationErr]; - Remove following code from the delegate.m file //setup audio session for background sounds. Allow iPod to continue if it's already playing. [[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil]; [[AVAudioSession sharedInstance] setActive: YES error: nil] 5. I cleaned, built and ran and it ran with no errors. The problem is that now the plugin is not playing the file from the url which it was before i added / modified the code to allow for streaming while in any sleep, mute or lock modes. Any help would be great. Thanks
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
12/16/12 10:45 PM (11 years ago)
Hey Rad Doc! I am going to play around with this. Let you know what I find. I am sure Danny will chime in at some point as well. Happy Holidays:) ian
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/17/12 03:01 AM (11 years ago)
Hi Rad Doc, Don't completely understand what you are trying to say but I guess the answer to your question lies in the modifications you have to make in you appDelegate. Follow this link and look for the last lines of the article. There is a manual with instructions on how to use the plugin in older projects. Follow them and all should be right. http://www.bt-addons.com/the-plugins/the-audiostreamer-plugin.html Let me know if this is the answer to your question. Best regards, Danny
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/17/12 04:02 AM (11 years ago)
Hey Ian and Danny , Thanks for the replies. @ Ian, Thanks, let me know what you find out @ Danny , I guess what I am trying to say is how can I allow your plugin to keep playing when the phone goes into sleep or silent mode? The manual for older projects doesn't pertain to my project.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/17/12 04:40 AM (11 years ago)
Hi Rad Doc, The plugin should play in the background with no problem. But if it's an older project you need to import the neccessary framworks and make edits in the appDelegate. For newer projects you don't have to do anything. But remember: the background audio and volumeslider, as stated in the manual, won't work in the simulator and only on an actual device. Hope this helps. Best Regards, Danny
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/17/12 05:06 AM (11 years ago)
Hi Again, Just did some testing. If audio plays it won't go into sleep mode and continues playing in the background. When I hit the button on top of the phone (to close the screen/phone) --> audio still plays. If I set the (hardware)volume button to mute --> audio still plays Tested on iPhone 4gs ios6 Can you confirm this? Best Regards, Danny
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/17/12 05:48 AM (11 years ago)
Danny, I'm gonna download a new package and start from scratch. I will test and let you know shortly. Thanks man, Anthony
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/17/12 09:27 AM (11 years ago)
Ok, So i reloaded a new package and tested the audio.It corrected my issue but there is one thing i needed to do to allow it to always play. It does not continue to play when closed unless you enter the UIBackgroundModes as an array and the app plays music as a string. This was tested on iPhone 4g, IOS 6.0. Thanks for your help Anthony
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/17/12 10:24 AM (11 years ago)
Hi Anthony, What do you mean by "unless you enter the UIBackgroundModes as an array"? I really don't get that part.... What should you do....... Thanks for testing. Best Regards, Danny
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/18/12 09:06 AM (11 years ago)
You have to set-up the continuous audio by adding a UIBackgroundModes to your app Custom IOS Target Properties. This is the Target properties 'info' screen where the Bundle Indentifier, Bundle Name and Icon File are stored. You add a row to this and call it UIBackgroundModes. Xcode will then changes that rows name and set-up an array with some dynamic fields. Thyen add the one that is called APP Plays Audio. At least this is what i did and it works fine for me. Before i added this is did not play when locked.
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/18/12 09:12 AM (11 years ago)
Hi Rad Doc, Now I understand.... working for so long on this plugin with the same project that I completely forgot that you need to do this. Thanks for pointing this out!!!! I'll update the manual Best Regards, Danny
 
ianJamesPiano
Code is Art
Profile
Posts: 2661
Reg: Feb 13, 2011
Palm Springs, C...
37,010
like
12/18/12 09:46 AM (11 years ago)
Nice work guys!
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/18/12 10:13 AM (11 years ago)
Thanks Ian, I updated the manual and want to thank you again Rad Doc for pointing this out!! http://www.bt-addons.com/the-plugins/the-audiostreamer-plugin.html Best Regards, Danny
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/21/12 12:23 PM (11 years ago)
Hey Danny, Would it be possible to add a feature that would allow the next track to automaticaly play as soon as the first track ends. Anthony
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/21/12 12:45 PM (11 years ago)
Hi Rad Doc, The plugin was designed to create one screen per audio stream. Your feature request would be a complete turnover of what was build. So I'm sorry to say that this isn't possible. Best Regards, Danny
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/21/12 01:11 PM (11 years ago)
Dan, What if we were able to add a load next screen option after finished in the cp? This would allow us to assign the next screen that should play. Using the same concept that Atrain used in his video player. Just a thought. If it can be done, so be it! Merry Christmas
 
PSMDanny
Apple Fan
Profile
Posts: 1166
Reg: Dec 09, 2011
Heerlen
21,940
like
12/21/12 02:23 PM (11 years ago)
Hi Rad Doc, There are many ways to develop a concept around an audio player. Not every concept covers the needs of every user. With this plugin I tried to make it usable for almost every user. Changing the way it's working now and to meet your requirements would probably involve more code changes than you, at first sight, can imagine. For now I think it's a pretty stable release that can be used by a big audience and it's easy to use. Maybe in the future new features will be added, depending on what the users want but feel free to dive into the code and try to get things done the way you like. I get customization questions for my plugins almost on a daily basis but unfortunately I can't do them all. Hope this clarifies a bit. Whish you also the best Christmas ever!!! Best Regards, Danny
 
Rad Doc
Apple Fan
Profile
Posts: 653
Reg: Oct 08, 2010
USA, NYC
8,580
like
12/21/12 03:03 PM (11 years ago)
No sweat. I appreciate your help. Cheers
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.