Stop or play don't work on mplayer

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Stop or play don't work on mplayer

Post by JosepM » Fri Feb 24, 2012 1:00 am

Hi,

I need help. I just try to create a player to listen online radios from a .pls file from a server. Only I need play and stop.

The app start playing the radio fine without problem, but when I try to stop or play again nothing happen. :(
I have two buttons that call "PauseRadio" and "PlayRadio".

Also if I try to trap the message that appear into the iOS documentation nothing happen...

What I'm missing?

I have this code:

Code: Select all

sPlayerID
on opencard
      if the environment is "mobile" then
            iphoneControlCreate "player" 
            put the result into sPlayerID
            iphoneControlSet sPlayerID, "fileName", "http://www.rac1.org/audio/Player/nou_listen.pls"
            iPhoneControlSet sPlayerID, "shouldAutoplay", "true"
            iphoneControlDo sPlayerID, "prepareToPlay"
            iphoneControlDo sPlayerID, "play"
      end if
end opencard

on closeCard
      if the environment is "mobile" then
            iphoneControlDelete sPlayerID
      end if
end closeCard

on PlayRadio
   iphoneControlDo sPlayerID, "play"
end PlayRadio

on StopRadio
   iphoneControlDo sPlayerID, "stop"
end StopRadio

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Stop or play don't work on mplayer

Post by Dixie » Fri Feb 24, 2012 1:44 am

Hi Joseph..

I just tried your code on an iphone... it works without any problems.... the only alteration that I made to your code is that I declared your variable by placing 'local' in front of 'sPlayerID' on the first line...

I've attached the stack...

be well

Dixie
Attachments
Untitled 1.livecode.zip
(1.8 KiB) Downloaded 258 times

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: Stop or play don't work on mplayer

Post by JosepM » Fri Feb 24, 2012 8:30 am

Hi Dixie,

Yes, with the Local work fine... :)

Salut,
Josep

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: Stop or play don't work on mplayer

Post by JosepM » Fri Feb 24, 2012 4:55 pm

Hi,

Now I have other issue with the audio. I want that when the app start, begin to play the radio streaming, this is ok, but when I go to other card the music stop. I these card I use a browser object to load the Facebook fan page of the radio and in other card I want to use other browser to show the youtube channel.

Why the music streaming stop? I move the script to a stack level but happen the same.

Maybe I can use groups and show and hide them, but the browser don't work into a group.

Thoughts?


Salut,
Josep M

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Stop or play don't work on mplayer

Post by Dixie » Fri Feb 24, 2012 7:34 pm

Joseph...

The music stops playing because you are 'destroying' the control when closing the card..

Code: Select all

on closeCard
      if the environment is "mobile" then
            iphoneControlDelete sPlayerID
      end if
end closeCard
if you make the 'player' invisible when you create it, you can then move to another card and back again and the music will continue to play. See the changes to creating the player in the openCard handler... and notice that I have commented out the 'iphoneControlDelete' command in the closeCard handler.

Code: Select all

local sPlayerID
on opencard
   if the environment is "mobile" then
      if sPlayerID is empty then
         iphoneControlCreate "player"
         put the result into sPlayerID
         iphoneControlSet sPlayerID, "fileName", "http://www.rac1.org/audio/Player/nou_listen.pls"
         iPhoneControlSet sPlayerID, "shouldAutoplay", "true"
         iphoneControlDo sPlayerID, "prepareToPlay"
         iphoneControlSet sPlayerID, "visible", "false"
         iphoneControlDo sPlayerID, "play"
      end if
   end if
end opencard

on closeCard
   if the environment is "mobile" then
      --iphoneControlDelete sPlayerID
   end if
end closeCard

on PlayRadio
       iphoneControlDo sPlayerID, "play"
end PlayRadio

on StopRadio
   iphoneControlDo sPlayerID, "stop"
end StopRadio
and, the browser does work within a group...

be well

Dixie

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: Stop or play don't work on mplayer

Post by JosepM » Fri Feb 24, 2012 7:42 pm

Oppsss... :oops:


Thanks!
Josep M

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Stop or play don't work on mplayer

Post by Dixie » Fri Feb 24, 2012 7:50 pm

Joseph...

I have just reread my post... the idea behind making the player invisible, since it's music you don't need to see it, is when you go to another card it won't clash with another native control that you might wish to use of the next card that you are going to... like the 'browser' control you mentioned...

be well

Dixie

JosepM
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 344
Joined: Tue Jul 20, 2010 12:40 pm

Re: Stop or play don't work on mplayer

Post by JosepM » Fri Feb 24, 2012 8:57 pm

Hi,

Yes, so I need only one 'player' control, and I can have one 'browser' control on each card, right? Should be work, isn't?
Maybe better that deal with groups.

Salut,
Josep M

archer2009BUSknbj
Posts: 72
Joined: Sat Apr 06, 2013 8:09 am

Re: Stop or play don't work on mplayer

Post by archer2009BUSknbj » Tue Apr 30, 2013 12:04 pm

Dixie wrote:Hi Joseph..

I just tried your code on an iphone... it works without any problems.... the only alteration that I made to your code is that I declared your variable by placing 'local' in front of 'sPlayerID' on the first line...

I've attached the stack...

be well

Dixie

I tried to save the attached LiveCode file as a standalone Android App APK File - but a message comes up saying not supported on this platform
Is there a way to may a basic player like this work on both Android and iPhone with a single CodeBase or do we need to detect which device is being used and use something different for each platform?

Dixie
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1336
Joined: Sun Jul 12, 2009 10:53 am

Re: Stop or play don't work on mplayer

Post by Dixie » Tue Apr 30, 2013 12:24 pm

Wherever in the script it has 'iphoneControl...', change the syntax to 'mobileControl...' ... that should make it work ! I can't see any other iphone specific things in the scripts, looking over it quickly...

Dixie

Post Reply