In Titanium, When the window opens the sound should autoplay . Sometimes it does but mostly it doesnt and sometimes it plays for a millisecond. As the hund.js opens the sound should play.
I have checked the mp3clips and there is nothing wroing with them.
the soundbit: http://pastie.org/8729002
the full code for the win + soundbit: http://pastie.org/8729003
Im new to programming so I really cant figure this out.
Try moving player.play(); to the very bottom after hundwin.open();
The hundview may be taking focus away from your global player.
Related
I have a VideoView in android that correctly plays a single video. It handles video fine with respect to muting, looping, etc.
I want to be able to switch between videos, however. To that end, I have two uris. I set the initial video like this:
_videoView = findViewById(R.id.video);
_videoView.setVideoURI(firstURI);
_videoView.requestFocus();
_videoView.start();
When I press Button2, it switches to the second uri like so:
_videoView.setVideoURI(secondURI);
_videoView.start();
When I press Button 1, it switches back to the first:
_videoView.setVideoURI(firstURI);
_videoView.start();
That all works fine, but after switching the uri a few times (sometimes as few as three, sometimes as many as seven; three or four is typical), the app freezes. It simply stops responding. There's no error in the log, nothing on screen, and no memory leak that LeakCanary can find. It simply stops responding and never recovers. This happens every single time.
Is there something wrong with how I'm changing the videos for this VideoView? (And yes, I want to use a VideoView.)
First Check your video is available or not then stop this video.It's better for you
Currently your first video still available in _videoView and you are playing another on same.
if (videoView!=null){
_videoView.stopPlayback();
_videoView.setVideoURI(URL);
_videoView.requestFocus();
_videoView.start();
}else{
_videoView.setVideoURI(URL);
_videoView.requestFocus();
_videoView.start();
}
I am using Python Kivy for an Android Game. I want to play a sound on an event
sound = SoundLoader.load("sound.wav")
def onEvent():
sound.play()
, and It works. But now the problem: Of course an event can, and in my case will happen again before the sound is done playing from the last event. And as the sounds are based on a play/pause idea I am getting a problem playing multiple sounds of the same object at once. That can be solved like this for first:
onEvent():
SoundLoader.load("sound.wav").play()
As this creates a new object all the time, and so is able to play it the same time another event plays the sound. But the problem using this method is quite obvious, because the sound must be loaded everytime the event occurs, and so causes a delay until it's played.
Is there a more useful way to do this?
{ if you don't understand what I am talking about, or just don't see the problem, feel free to ask }
You can workaround this by loading multiple instances of the sound.
For instance
sounds = [SoundLoader.load("sound.wav") for _ in range(10)]
index = 0
and then
def play():
sounds[index].play()
index = (index + 1) % len(sounds)
The more sounds you load, the more instances you can have playing at the same time (in this example 10).
We are trying play audio from url (m3u8 file). Media player starts fine no issues. Audio also plays cleanly. Issue starts when do seek in the player. Behavior very strange. it seeks to the proper position then starts playing audio. After while it seeks again like couples seconds (better word is skips some seconds since it jumps to the position directly) and can be observed in the media playback time counter, again plays for a while again jumps some seconds and this continues till end of the media.
We have our custom seek bar which is nothing but a progressbar, and when we do seek the progress bar we send same seek position to media player by calling onseek() method.
Note: Issue Happens only Lollipop nexus devices(tablet and phone).
Strange observation jump happens only if the time counters last position 9
(i.e if mediaplayed 12:29[mm:ss] then will jump to some other random place 12:3X[mm:ss],again mediaplayed 12:39[mm:ss] then will jump to some other random place 12:4X [mm:ss] )
Why is it happening?
You should pass the outer manifest to the player. This should resolve your issue.
My app needs to record video with a maximum time of 8 seconds. This is already implemented with MediaRecorder.setMaxDuration(long milliseconds).
The app also needs a progress bar in the top and a label with a count down of the remaining time.
The problem here is that there's an offset between the UI and the MediaRecorder progress, and this leads to confusion in the user. For example, the user thinks that he/she recorded something because the progress in the UI said so, but the media recorder cut off the video a second earlier.
The challenge is to start the progress bar and counter at the exact same time as the recorder actually starts recording.
I've tried starting the timer after MediaRecorder.start(), in a callback when the created file is modified for the first time, but I haven't found a way to achieve this in a correct way. We tried setting a hard coded offset to these values but of course it didn't work the same for every device.
I wish there was a callback from the MediaRecorder to inform that it has actually started to record the video, or maybe the current length.
Is the problem clear? Has someone solved this before?
MediaRecorder has known issues with cutting off audio early. I implemented a recorder with a button - clicking the button to stop the recorder would actually yield an audio file with the last second cut off.
Not sure if your UI offset is a separate issue, but I would try extending the MediaRecorder by half a second after the user attempts to end it. You can either do this by changing the maximum time to 8.5 seconds, or just using this line of code:
android.os.SystemClock.sleep(500);
Just to specify the question a little more, I will give an example. I have a car stereo and when I get in the car I can just press play and it plays the last song I was listening to on my phone. So what I need is like a very general Android button that does just that. I just want this button to start media. It's difficult to explain but I know like Google Music when you open it always has a song at the bottom that you can press play. So it's kind of like just continuing a previous queue? If more details are needed please let me know. Sorry I do not have any code for this problem because I have never worked with media but if you would like the source to my app that this code will go into please visit
http://mellowdev.net
The app is called Mango. Open source.
EDIT: I have tried the following but nothing plays.
MediaPlayer mediaPlayer = new MediaPlayer();
int position = mediaPlayer.getCurrentPosition();
mediaPlayer.seekTo(position);
mediaPlayer.start();
As I understand you want to play the music from last known position (or better say from the last known time of the sound). It's something similar like the user change the orientation then you want to play the sound from current position and don't want to start the sound again.
Therfore you have two method in the MediaPlayer:
int position = mediaPlayer.getCurrentPosition();
mediaPlayer.seekTo(position):
I think this post will help you (the example is for a VideoView, but it should be similar to the MediaPlayer).
Hope this will help you :)
EDIT (2013 08 16)
// create a MediaPlayer Instance with the sound you want to play
MediaPlayer mediaPlayer = MediaPlayer.create(context, mySound);
I couldnt't exactly understand your code. But if you need to play media in android, you need to create instance of MediaPlayer and can start to play using a button. Below link will give you more insight:
http://developer.android.com/guide/topics/media/mediaplayer.html
Sorry if I mis understood your question.
To just launch music player:
Intent intent = new Intent(MediaStore.INTENT_ACTION_MUSIC_PLAYER);
startActivity(intent);