Page 1 of 4

Music Player

Posted: Fri Jan 08, 2016 10:40 pm
by Ramzan
I have created a music player. I will change its name and track names later.

I hope to develop this as an app and sell it in the app store.

Can you tell me if this code is any good? Will it work on all iphones and iPads?

Code: Select all

SET UNDERGROUND ON
SET ORIENTATION PORTRAIT
SET TOOLBAR OFF
SET OUTPUT BACK COLOR 0,0,0
SET OUTPUT FONT SIZE 32
SET OUTPUT FONT COLOR 0,0,1
SET BUTTONS FONT SIZE 24
DRAW COLOR 1,1,0
FILL COLOR 0,0,0
FILL AlPHA 0
SET BUTTONS CUSTOM
p=0


PRINT "Music Volume 1"
BUTTON "1" TEXT "Track 1" AT 30, 100
BUTTON "2" TEXT "Track 2" AT 30, 200
BUTTON "3" TEXT "Track 3" AT 30, 300
BUTTON "4" TEXT "Track 4" AT 30, 400
BUTTON "5" TEXT "Track 5" AT 30, 500
BUTTON "6" TEXT "Stop" AT 30, 700


LOOP:

IF BUTTON_PRESSED("1") THEN 
IF p=1 THEN
MUSIC 1 STOP
MUSIC 1 DELETE
END IF
MUSIC 1 LOAD "files/musictrack1.wav"
MUSIC 1 PLAY
p=1
END IF

IF BUTTON_PRESSED("2") THEN 
IF p=1 THEN
MUSIC 1 STOP
MUSIC 1 DELETE
END IF
MUSIC 1 LOAD "files/musictrack2.wav"
MUSIC 1 PLAY
p=1
END IF

IF BUTTON_PRESSED("3") THEN 
IF p=1 THEN
MUSIC 1 STOP
MUSIC 1 DELETE
END IF
MUSIC 1 LOAD "files/musictrack3.wav"
MUSIC 1 PLAY
p=1
END IF

IF BUTTON_PRESSED("4") THEN 
IF p=1 THEN
MUSIC 1 STOP
MUSIC 1 DELETE
END IF
MUSIC 1 LOAD "files/musictrack4.wav"
MUSIC 1 PLAY
p=1
END IF

IF BUTTON_PRESSED("5") THEN 
IF p=1 THEN
MUSIC 1 STOP
MUSIC 1 DELETE
END IF
MUSIC 1 LOAD "files/musictrack5.wav"
MUSIC 1 PLAY
p=1
END IF

IF BUTTON_PRESSED("6") THEN 
IF p=1 THEN
MUSIC 1 STOP
MUSIC 1 DELETE
END IF
p=0
END IF

GOTO LOOP

The idea is that when a user presses a track it deletes the current music, loads the new music and plays it.

This is the first time I have ever programmed anything in my life.

Re: Music Player

Posted: Sat Jan 09, 2016 5:04 am
by Mr. Kibernetik
Congratulations! Happy programming!

Re: Music Player

Posted: Sat Jan 09, 2016 8:18 am
by Henko
Ramzan wrote:I have created a music player. I will change its name and track names later.
I hope to develop this as an app and sell it in the app store.
Can you tell me if this code is any good? Will it work on all iphones and iPads?
The idea is that when a user presses a track it deletes the current music, loads the new music and plays it.
This is the first time I have ever programmed anything in my life.
Hi Ramzan,
Your first program works well, but needs more flexibility and a lot of optimalizations are possible.
The best thing you can do is look & learn from the numerous examples and other programs in this section.
If you encounter specific problems, which are not covered by the help manual you can ask them here and someone may help you out.

As for selling an app in the app store: have you thrown an eye on the potential competition for this kind of app?

Re: Music Player

Posted: Sat Jan 09, 2016 2:05 pm
by rbytes
Hello, Ramzan. I just tried your player with some of my songs, and it worked fine. With the toolbar disabled, you need to provide a button to end the program. Otherwise the user has to quit smart BASIC, restart it and reload your program to make any adjustments.

The current version of smart BASIC can not directly load songs from the music library. This is a feature request which I hope will be coming soon, but in the meantime you will need to use other apps to copy some songs into a smart BASIC folder so that they can be played. This is no problem for someone who has smart BASIC, but it would not be practical to ask the average user to transfer their music this way.

As Henko says, there are many good example scripts on the forum to help you with your learning. And if you get stuck, other users will help you. Good luck in your journey. :)

Re: Music Player

Posted: Thu Jan 21, 2016 8:37 pm
by Ramzan
I don't understand.

I have created 12 music tracks using an app on my iPad.

I want to create an app that will contain all 12 tracks.

I don't want access to a person's music library. I want them to start my app and listen to my music.

That is what my Smart Basic app does - it contains 12 music tracks that the user can listen to.

Can I not create a Smart Basic app and then use the Xcode tutorial to convert it to an iOS app? I want it to be a stand-alone iOS app like every other app on the app store. In other words the app itself contains the music and the GUI for playing the music. I don't want people to need Smart Basic in order to load my app.

Re: Music Player

Posted: Thu Jan 21, 2016 8:44 pm
by Mr. Kibernetik
Ramzan wrote:Can I not create a Smart Basic app and then use the Xcode tutorial to convert it to an iOS app? I want it to be a stand-alone iOS app like every other app on the app store. In other words the app itself contains the music and the GUI for playing the music. I don't want people to need Smart Basic in order to load my app.
You can. Please look at announcement topics here: viewforum.php?f=34

Re: Music Player

Posted: Thu Jan 21, 2016 8:57 pm
by Ramzan
Now I,'m really confused. Are you saying that I can create a musc player app with Smart Basic that contains my music....

....then use Xcode tutorial to convert it to an iOS app....

....then sell the app on the app store...

...and people can buy my app.....

...and they can listen to the music that is contained in the app....

.....all without needing Smart Basic on their iPad or iPhone?

Re: Music Player

Posted: Thu Jan 21, 2016 9:08 pm
by Mr. Kibernetik
Ramzan wrote:Now I,'m really confused. Are you saying that I can create a musc player app with Smart Basic that contains my music....

....then use Xcode tutorial to convert it to an iOS app....

....then sell the app on the app store...

...and people can buy my app.....

...and they can listen to the music that is contained in the app....

.....all without needing Smart Basic on their iPad or iPhone?
Yes, of course. In the topic viewforum.php?f=33 you can see some apps which are made in sB and are selling in App Store.

Re: Music Player

Posted: Thu Jan 21, 2016 9:29 pm
by Ramzan
Thank you.

Re: Music Player

Posted: Fri Mar 18, 2016 9:08 pm
by Ramzan
I have a question. When I use BUTTON AT 30,700 it creates a button that is really far down the screen, near the bottom third in fact. I thought 30,700 meant 30 pixels to the right and 700 pixels down. Since the iPad Air 2's resolution is 1536 X 2048 in portrait mode the button should appear in the top third. So what's going on?