[Q] Hello, I have an issue with the media player on rotation - Android Software Development

I have a media file playing in the oncreate, and everytime i switch over to landscape it replays the audio file, i cannot restrict it from turning to land scape because thats the purpose of the app, is there any way i can possible pause the player and start it up again once its on landscape?
i tried
if(alert.isPlaying() == true){
alert.stop;
}else{
alert.start;
}
Click to expand...
Click to collapse
I just typed this out in this post so i know i made an error, im still new to android programming.
Please and thank you,
Alexander Napoles

Take a look at this.
You could also save if it has already been played in a variable.
Or make an extra class, maybe as activity to play to play the audio file. Use an addiotinaly variable to procted the class from being created twice, because we only want to play it once.
This should keep running in the background and not start again when going landscape mode because it is not part of the activity that is getting recreated when you switch your gui to landscape.

Thank you "Clicks Thanks button" Im going to be testing this out tomorrow morning.

Related

How to use (back,play,fwd) button in HTC Audio Manager on HTC Home plugin?

Hi, I have HTC Home6 plugin, along with HTC audio manager 1.02 installed.
However, the button on home plugin (back,play,fwd) does not work.
I have to actually open htc audio manager in order to play the songs. Did I miss something?
Also, can HTC audio manager sorts songlist by title?
or display chinese/japanese fonts in playlist?
When you use the tab to open your player - what player does it open?
If it opens WMP (which mine did by default) you need to edit the registry and change WMP to Audio manager. Wait a bit, turn the pda off the soft reset.
*I think* it's HKLM\Software\HTC\Music Plug-in\ and there is a value in there which needs to be changed from 1 to 2.
Values:
1 = WMP
2 = Audio Manager
Yes, but he means the buttons on the HTC Home player do not work, which is true.
I found you need to actually open the HTC player, start playing a song or playlist, THEN minimise (while its still playing) it and you can control it from the HTC Home plugin.
How can i edit registry? Do i need to type regedit somewhere like in windows?
Biohead said:
When you use the tab to open your player - what player does it open?
If it opens WMP (which mine did by default) you need to edit the registry and change WMP to Audio manager. Wait a bit, turn the pda off the soft reset.
*I think* it's HKLM\Software\HTC\Music Plug-in\ and there is a value in there which needs to be changed from 1 to 2.
Values:
1 = WMP
2 = Audio Manager
Click to expand...
Click to collapse
GuWa7 said:
How can i edit registry? Do i need to type regedit somewhere like in windows?
Click to expand...
Click to collapse
You need to install a registry editor. PHM Registry Editor is a very popular one and is free.
As I said above, changing that registry entry will only change the default media player. It WONT solve your problem.
well i think this is no problem, but the plugin is created to work like that, you have to launch the player then press ok button(the hardware one) to minimize and then control it trough the plugin. The same thing is with WMP today plugin, the plugin does not play the music, it launches WMP
the_scotsman said:
Yes, but he means the buttons on the HTC Home player do not work, which is true.
I found you need to actually open the HTC player, start playing a song or playlist, THEN minimise (while its still playing) it and you can control it from the HTC Home plugin.
Click to expand...
Click to collapse
Just think about it briefly. How can Audiomanager / WMP play any song if isn't running? That is a bit weird idea.
Same here xplode. Otherwise how else would you choose what music to start playing?
I only said what I said as I know that the control don't work for me IF I use WMP. If I use the audio manager the controls are fine once I've set it playing.
Wexx said:
Just think about it briefly. How can Audiomanager / WMP play any song if isn't running? That is a bit weird idea.
Click to expand...
Click to collapse
I think you need to re-read my post...this DOES work...you start the media player then MINIMISE it (not close it) and the plugin controls will be working...So I think you may need to think about it briefly...
I have the problem to
If i click on launch music wmp starts. but if wmp plays a song and i minimize wmp the plugin control doesnt work no title song or play or pauze.
You need to re-assign the HTC music player to HTC Audio manager for the buttons to work.
There's a HTC Home customizer floating around somewhere in the forum.
kimhoon said:
I have the problem to
If i click on launch music wmp starts. but if wmp plays a song and i minimize wmp the plugin control doesnt work no title song or play or pauze.
Click to expand...
Click to collapse
can screen be turned off and leave audio manager active - music plays,
or I have to use other players for listening music while walking?
Yes. It does work for me too...
the_scotsman said:
I think you need to re-read my post...this DOES work...you start the media player then MINIMISE it (not close it) and the plugin controls will be working...So I think you may need to think about it briefly...
Click to expand...
Click to collapse
Please, help AudioManager in WM06
I have read all posts of you, I certaintly guest audiomanager working good on BA (WM06), I use T-Mobile MDAIII installed Audiomanager which played during 2 minutes and suddently stop all, the sound could not turn on, I have to reset the device, everything turns back OK.
I wonder I got something wrong audiomanager version. Please give the good audiomanager version for me to get link. Thanks to read this post.
wakhoma:
Mine is HTC Audio Manager 1.02 inside cabs.rar from Helmi.
I have it playing like 5-6hrs non-stop (looping) last night without problem.
GuWa7:
The pause button works fine for me too from HTC home plugin.
the_scotsman said:
I think you need to re-read my post...this DOES work...you start the media player then MINIMISE it (not close it) and the plugin controls will be working...So I think you may need to think about it briefly...
Click to expand...
Click to collapse
Sorry. I haven't noticed I quoted wrong post. It was a reaction to the first one.
Hi biohead. Do you know the registry setting where I can change the default message application when i click on the message on the HTC Home. If I click on the envelope it points me to the MMS application instead of the outlook mail. Please help.
Biohead said:
When you use the tab to open your player - what player does it open?
If it opens WMP (which mine did by default) you need to edit the registry and change WMP to Audio manager. Wait a bit, turn the pda off the soft reset.
*I think* it's HKLM\Software\HTC\Music Plug-in\ and there is a value in there which needs to be changed from 1 to 2.
Values:
1 = WMP
2 = Audio Manager
Click to expand...
Click to collapse
Another reason
I known the reason why my device stopped all and no sound when using audio manager 1.02. Audio manager does not support 4GB SD card (Trancend economy). When I exchange it with my friend (his device uses 1GB SD card), the problem does not happen. Otherwise he use my SD card, he got the same problem as I did.
Hope, this post would be helpful for someone. Thanks
the_scotsman said:
I think you need to re-read my post...this DOES work...you start the media player then MINIMISE it (not close it) and the plugin controls will be working...So I think you may need to think about it briefly...
Click to expand...
Click to collapse
Sorry madam, I DID read your post, you should read ours, NO it does NOT work, I m listening the music and the HTC Home plugin says Launch Music Player, any way to edit the registry or another way to make this work? Thank you

Trick mediaplayer to play MP3 streams?

Hi, is there a way to trick the standard mediaplayer to play a mp3 stream rather than a file?
The mediaPlayer Object from the SDK just takes any source not matter if the link points to the lokal filesystem or a link to a website. But I don't get it to work :/
I try to play http://www.motor.de/extern/motorfm/stream/motorfm.mp3 for example and I tried to put it into a m3u playlist. But the mediaDetectorServer (or whichever) always deletes this file. Any other ideas?
[Edit] Before someone asks: I try to use this for my alarm clock to get woken up by internet radio.
You are a brave man. Do you really want to risk being late to work because 3G/Edge/Wifi was down?
Sorry, I don't have an answer to your problem. I use StreamFurious for my Internet radio needs.
You know anything about linux? Create a fifo named "something.mp3", dump the network stream into the fifo, play the fifo. Should work. I'm not going to bother trying though since it really doesn't matter to me. If you don't know what I said, then google search is your best friend.
tulamidan said:
Hi, is there a way to trick the standard mediaplayer to play a mp3 stream rather than a file?
The mediaPlayer Object from the SDK just takes any source not matter if the link points to the lokal filesystem or a link to a website. But I don't get it to work :/
I try to play http://www.motor.de/extern/motorfm/stream/motorfm.mp3 for example and I tried to put it into a m3u playlist. But the mediaDetectorServer (or whichever) always deletes this file. Any other ideas?
[Edit] Before someone asks: I try to use this for my alarm clock to get woken up by internet radio.
Click to expand...
Click to collapse
Hm... dunno sound like a bit of a hassle to me. Might work all right though wit gScript. Hm...
Well I'm having a try with modifying the source of the musik.apk and/or the alarm.apk let's see how far I get.

refresh the music tab library

Does anyone know an other way to refresh the music player library, than having to softreset the device?
Maybe a solution would be to just reloud the sense today plugin, but i haven't found an easy way to do that eighter.
Any idea is welcome. I really don't wanna softreset my device everytime I downloaded a podcast. I have to softreset enough as it is every time it crashes.
Greetings
chuelbrueder
Well, one way is to launch Windows Media Player, go to its library and reindex media.
when on the music tab click "library" then go into artists and select what you want to listen to. seems to work on mine without having to reindex
chuelibrueder said:
Does anyone know an other way to refresh the music player library, than having to softreset the device?
Maybe a solution would be to just reloud the sense today plugin, but i haven't found an easy way to do that eighter.
Any idea is welcome. I really don't wanna softreset my device everytime I downloaded a podcast. I have to softreset enough as it is every time it crashes.
Greetings
chuelbrueder
Click to expand...
Click to collapse
See this thread's first and second post. Maybe this wil answer some of your questions about the Music player crashes. Please relay the info
http://forum.xda-developers.com/showthread.php?p=5220474

[Q] Default media player

Hello everyone,
i'm trying to do a podcast software, but i can't find a way to play music througth the default media player.
What should i use?
I use now Mediaplayer() but it has no user interface (no pause, forward ...) which is pretty annoying.
Thank you for your answers!
Have you looked at the MediaController class:
http://developer.android.com/reference/android/widget/MediaController.html
By now, i used another method with Intent.
String path = "/sdcard/feed/"+ title+"/"+fileName + ".mp3";
Intent myIntent =new Intent(android.content.Intent.ACTION_VIEW);
myIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
myIntent.setDataAndType(Uri.parse("file://"+ path),"audio/*");
startActivity(myIntent);
Which actually works for mp3s.
I am looking for the basic Android downloader (the one used by the market for example)
Do you know how to use it?
Thank you a lot
So you want to download the file first to the sdcard, then play it by launching the default program for MIME type "audio/*"? seems convoluted. The MediaPlayer object will do all this for you in streaming mode and the MediaController class will give you a nice interface.
Otherwise, I don't know what you mean by "basic Android downloader".

[Q]How to rip streaming music radio app

I have an Online Radio App and would like to add some sort of recording feature on it. I have done quite a bit of research and found one solution and from what I understand maybe the only solution is to rip it byte by byte. I have also tried to use the built in android recording method but it only records from the mic and I do not know or cannot figure out how to record from an external source such as a url like http://92.68.34.221:7000. Currently I am using the default Android media player method to play the url and its working flawlessly problem is I would like to set up the recording feature as a service to where when a the button is clicked run the service start recording and when it is clicked again terminate the service and save the file in a folder called online radio. Button might end up being a ToggleButton. I would really appreciate it if anyone could help me out and steer me in the right direction. Thanks in Advance
Saving a stream to file is quite easy, but if you want to define the exact start and end point of saving/recording by a button click it gets difficult.
You'll have to change your implementation a lot. Your android mediaplayer class handles everything for you, it opens the stream, fills a buffer and starts playing when the buffer is full. The mediaplayer doesn't offer any access to the bytes that it received.
Next problem: If you click on the button to start recording, the bytes you are listening to, have been in the (internal) buffer for an unknown amount of time. So you can't just open another connection to the stream url to start saving the bytes.
I would try it this way:
Implement these three parts in three different threads.
1. Use android.media.MediaExtractor to open the stream and implement a ringbuffer to store the extracted bytes
2. Use android.media.MediaCodec to decode your stream to pcm.
3. And use android.media.AudioTrack to play the pcm stream
Choose the size of the ringbuffer as large as the buffer of the AudioTrack. (Size in seconds, not in bytes!)
When the user clicks on the record button, you can read the data out of the ringbuffer, (encode them back to mp3 or something else) and save them to a file.
Not very easy for a beginner, but its a way you can do it.

Categories

Resources