I have the following code which works for Google Play Music, partly for Poweramp, not at all for stock music player
public void playSelectedPlaylist(String plid) {
Intent intent = new Intent( MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH);
intent.putExtra(MediaStore.Audio.Playlists.ENTRY_CONTENT_TYPE,
"android.intent.extra.playlist" );
intent.putExtra(MediaStore.EXTRA_MEDIA_FOCUS, "vnd.android.cursor.item/playlist");
intent.putExtra(SearchManager.QUERY, plid);
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}else{
doToast("Sorry, no app was found to service this request", context);
}
}
The intent is INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH and it finds all those apps that have this in their manifest.xml file. So far so good. However, some of these are not really suitable for mp3 playlists such as Youtube.
Question 1:
How can I return just music players. (the MUSIC_PLAYER activity has been deprecated so I need to use seomething else)
Question 2:
when executing the above code Poweramp does present the user with the appropriate playlist. When clicking this and select "Play" nothing happens other than Poweramp asking me if I want to play filtered or play all. Selecting either has no effect.
Finally the question, why does Poweramp not play the playlist?
Additional:
the reason why the stock music player does not show is because it does not have the INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH. (I assume this will change in later versions)
Google Play Music has no problem and happily loads and starts to play the playlist
My Samsung has another music player which loads but seems unable to recognise it is a playlist I am passing and does not find anything although the playlist exists.
Anyone with suggestions, thoughts/suggestions I can try out?
Related
How do you play another item when the one playing is finished (think playlist...)
I want to be able to create a new AVPlayerLayer and attach a player to it and start it in the background (ie. audio only).
Thanks
I know I can keep the audio of a streaming video in the background by doing self?.playerLayer?.player = nil when leaving the foreground. That is not what I am asking about.
You can skip a playerLayer if you like. AVPlayerLayer is only a visual class that uses an AVPlayer.
player = [AVPlayer playerWithURL:theURL];
[player play];
or
[yourPlayerLayer.player play]
Bob's your auntie
How can I link different tracks present in a particular tab on spotify page, so that when clicked on spotify next/previous button the next/previous track is played. Presenlty it is not playing anything if clicked on next button, when it should be starting to play the next track present on the page
My script looks like this,
$.each(allTracks,function(index,track){
models.Track.fromURI(track, function(track) {
models.Album.fromURI(track.album.uri, function(album) {
var single_track = models.Track.fromURI(track.uri);
var single_track_playlist = new models.Playlist();
single_track_playlist.add(single_track);
var pl = new views.Player();
pl.context = single_track_playlist;
if(index==0) {
$("#firstTrack").append(pl.node);
}
.............
.............
Can anyone please guide me on how I should be going around doing this? Thank you in advance
In your case, the context of each Player view is a playlist with that single track. If you want to render your tracks as players, and have them synchronized so that the next track plays after the one before ends, you need to create a custom solution.
You can check this Grid Play Spotify App, that shows an example of how to achieve it. It basically creates custom Player views that respond to certain events triggered by the Player model and other Player views.
I have a MonoTouch AVAudioPLayer that i want to play whenever an event occurs.
My code looks like this:
...
AVAudioPlayer player = AVAudioPlayer.FromUrl(url);
...
public void handleEvent(object sender, eventArgs e)
{
player.Play();
}
But if the event occurs again before the player is finished playing the sound, it will not fire again, waiting until the sound is complete before accepting another .Play() command.
How can get the sound to fire regardless of whether it is already playing?
AVAudioPlayer isn't a good choice for sound effects--it's meant more for making a music player. (It also pauses any music playing in the background like iTunes or Pandora)
Try using system sounds, see here: How can I play a sound on the iPhone using MonoTouch?
I'm trying to play a song from a position other than the beginning of the track.
I've found that player.position = X will work as a standalone function, such as triggered by a button, but triggering it on player.observe(models.EVENT.CHANGE... results in a crash.
I figure this is because the track hasn't actually started playing once the event occurs as the player.position may still be at the previous song's position.
I've also experimented with sp.trackPlayer.seek() which seems to give the same results.
So has anyone got a song to start playing at another position than 0? (Or made the playhead jump ahead after the event of playing a new song?)
Add the position after the uri, for example:
var uri= 'spotify:track:xxxxxx#02:04'
player.playTrackFromUri(uri)
See this sourcecode if you want inspiration:
https://github.com/Iteam1337/Wejay/blob/master/javascript/room.js
Reference iOS TabController app...
Apple docs state that the AVAudioPlayer class does not provide support for streaming audio based on HTTP URL's. AVAudioPlayer plays only music embedded in the iApp with a file:// as a url.
Given that, I do use MPMoviePlayerViewController to play these web stored audio/mp3 files which it can handle.
This definitely works. I start out with a UIView with the lyrics for the song. At the very bottom of this UIView is a "Play" button. The user taps this button and the audio/mp3 plays; however, the audio/QuickTime (( Q )) graphic comes to the foreground and the lyrics disappear and will stay away until the user taps "Done". What I want to happen is that the audio/mp3 is played in the background, with the lyrics staying in front.
BTW, I really don't need for the "Done" button to be seen because the user can stop the audio by simply selecting another Tab.
Obviously this going to the background for the AV file makes sense because the MPMoviePlayerController object is designed to play video and the video ought to come to the front. It is consistent in that the audio also goes to the background .. except I need a way to defeat the audio/QuickTime (( Q )) graphic coming to the front.
I did insert code to determine if it was an audio file (mp3), versus a video file (mp4). So far so good ... and then if it was an audio file, within my actual playing segment, I have:
if ( NSClassFromString(#"MPMoviePlayerViewController") )
{
if (!isAudioFile)
{
[senderViewController
presentMoviePlayerViewControllerAnimated:moviePlayerViewController_];
}
}
[moviePlayerController_ play];
It actually works, that is, I actually hear the mp3 in the background, with the lyrics in front and the audio/QuickTime (( Q )) graphic does not show ...
BUT, what does happen is horrible, that is, the "Done" button shows over the lyrics I talked about with some sort of unknown ??? letters there.
The following answer is taken from an edit to the question:
if ( NSClassFromString(#"MPMoviePlayerViewController") )
{
if (!isAudioFile)
{
[senderViewController
presentMoviePlayerViewControllerAnimated:moviePlayerViewController_];
}
else
{
[moviePlayerController_ setControlStyle:MPMovieControlStyleNone];
}
}
FWIW, I really don't need a "Done" button because as soon as I go to another tab, either new music or a video, the music initially playing stops and the new AV file starts.