CLEO Help MP3 not play and crash

CLEO related
Status
Not open for further replies.

KazoVan

Member
Joined
Feb 8, 2017
Messages
11
Reaction score
0
MP3 not play and crash my game , fix help me please 


Code:
// This file was decompiled using SASCM.ini published by GTAG (http://gtag.gtagaming.com/opcode-database) on 14.6.2013
{$CLEO .cs}
 
//-------------MAIN---------------
 
0000: NOP
 
 
:BASE
wait 0
if
  Player.Defined($PLAYER_ACTOR)
else_jump @BASE
jump @missile
 
 
:missile
wait 5
if
0AB0:   key_pressed 88
jf @engine
$HMP1 = Audiostream.Load("CLEO/mp3/missile.MP3")
Audiostream.PerformAction($HMP1, PLAY)
wait 1000
jump @BASE
 
 
 
 
:engine
wait 5
if
0AB0:   key_pressed 78
jf @getlock
wait 200
$HMP2 = Audiostream.Load("CLEO/mp3/online.MP3")
Audiostream.PerformAction($HMP2, PLAY)
wait 2000
jump @BASE
 
 
 
:getlock
wait 5
if
0AB0:   key_pressed 49
jf @missile
$HMP3 = Audiostream.Load("CLEO/mp3/getlock.MP3")
Audiostream.PerformAction($HMP3, PLAY)
gosub @stop
wait 1000
jump @BASE
 
 
 
 
:stop
if
0AB0:   key_pressed 50
else_jump @STOP
Audiostream.Release($HMP1)
Audiostream.Release($HMP2)
Audiostream.Release($HMP3)
jump @BASE
 

MrChristmas

Expert
Joined
Jul 29, 2014
Messages
563
Reaction score
26
Make sure your path is set up right, big letters and small letters.
If I remember correctly there's a maximum size of .MP3 that you can use.
Release 3 HMP's before you set one to play.

You can also try and have a look at this: http://ugbase.eu/Thread-UPDATE-v1-2-RELEASE-MP3
 

KazoVan

Member
Joined
Feb 8, 2017
Messages
11
Reaction score
0
http://ugbase.eu/Thread-UPDATE-v1-2-RELEASE-MP3 , crash my game , how i can fix code to play mp3 when i want...
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
just tested it and it worked with cleo 4.1 and samp 0.3.7 


Code:
{$CLEO .cs}
0000: NOP

/* this part requires sampfuncs
repeat
wait 50
until 0AFA: is_samp_structures_available
*/

repeat
wait 50
until 056D: actor $PLAYER_ACTOR defined

while true
wait 0
    if key_down 50 // 2 (not numpad)
    then
        0AAE: release_mp3 $hMP1
        0AAC: $hMP1 = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
        0ABC: set_audiostream $hMP1 volume 1.0
        0AAD: set_mp3 $hMP1 perform_action 1 //0=stop, 1=play, 2=pause, 3=resume
        0AAF: 0@ = get_mp3_length $hMP1
        printf "Length:%d" 1000 0@
        wait 1000
    end
end
 

KazoVan

Member
Joined
Feb 8, 2017
Messages
11
Reaction score
0
monday said:
just tested it and it worked with cleo 4.1 and samp 0.3.7 


Code:
{$CLEO .cs}
0000: NOP

/* this part requires sampfuncs
repeat
wait 50
until 0AFA: is_samp_structures_available
*/

repeat
wait 50
until 056D: actor $PLAYER_ACTOR defined

while true
wait 0
    if key_down 50 // 2 (not numpad)
    then
        0AAE: release_mp3 $hMP1
        0AAC: $hMP1 = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
        0ABC: set_audiostream $hMP1 volume 1.0
        0AAD: set_mp3 $hMP1 perform_action 1 //0=stop, 1=play, 2=pause, 3=resume
        0AAF: 0@ = get_mp3_length $hMP1
        printf "Length:%d" 1000 0@
        wait 1000
    end
end

Ok , frist it play it working , but when i active 2 or 3 times cleo working , but I do not hear music , this my audio game error or something???
 

monday

Expert
Joined
Jun 23, 2014
Messages
1,127
Solutions
1
Reaction score
158
idk, I just tried spamming it and it worked like 20/20 times, maybe you have another cleo which gets activated and interferes with "$hMP1"? Just a guess

Edit: You could use a local variable like "1@" to keep the handle of the audiostream. I was always using  "$hMP1" because that's how it was in other mods but it seems that it's not necessary. The 0AAC returns integer, idk what are the limits and didn't fully test the functionality of multiple audiostreams loaded at the same time but it looks like there can be a lot of them

the code below prints: "Length: <length> Handles: 0 1 2 3 4 5 6
Code:
0AAE: release_mp3 31@
0AAC: 31@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
0ABC: set_audiostream 31@ volume 1.0
0AAD: set_mp3 31@ perform_action 1 //0=stop, 1=play, 2=pause, 3=resume
0AAF: 0@ = get_mp3_length 31@


0AAC: 30@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
0AAC: 29@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
0AAC: 28@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
0AAC: 27@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
0AAC: 26@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"
0AAC: 25@ = load_audiostream "CLEO/music/FKA Twigs - Two Weeks.MP3"

printf "Length:%d Handles: %d %d %d %d %d %d %d" 1000 0@ 31@ 30@ 29@ 28@ 27@ 26@ 25@

Edit2: On the other side using global variables for the audostream handles is a good idea because the audiostreams are not loaded separately for each cleo. So if you hypothetically have 2 cleos, 1 which loads audiostream (handle = 0) and the other one which uses "0AAD: set_mp3  0  perform_action 1" the music will start playing...
 
Status
Not open for further replies.
Top