Well…A few days ago, I was working in an app to listen podcasts and I needed an audio player. I decided to developed a small framework to do it and after open it. So, I openned my android audio player source:
https://github.com/tassioauad/Android-My-Audio-Player
That’s the version 0.1 and I’m working on a version 0.2 where we can set a custom layout to the player. The framework 0.1v user guide is here: https://github.com/tassioauad/Android-My-Audio-Player/wiki/%5BVersion-0.1%5DSmall-User-Guide
An example:
Full xml layout code: (activity_main.xml)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" | |
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin" | |
android:paddingRight="@dimen/activity_horizontal_margin" | |
android:paddingTop="@dimen/activity_vertical_margin" | |
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity"> | |
<com.tassioauad.library.view.PlayerViewComponent | |
android:id="@+id/player" | |
android:layout_height="wrap_content" | |
android:layout_width="match_parent" | |
android:layout_alignParentBottom="true" | |
/> | |
</RelativeLayout> |
The full Activity code:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class MainActivity extends Activity { | |
@Override | |
protected void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.activity_main); | |
PlayerViewComponent player = (PlayerViewComponent) findViewById(R.id.player); | |
AudioEntity audioEntity = new AudioEntity() { | |
@Override | |
public String getImageUrl() { | |
return "http://mediad.publicbroadcasting.net/p/kcur/files/201309/waitwaitnew.jpg"; | |
} | |
@Override | |
public String getTitle() { | |
return "NPR Wait Wait"; | |
} | |
@Override | |
public String getSubTitle() { | |
return "podcast episode n"; | |
} | |
@Override | |
public String getAudioUrl() { | |
return "http://podcastdownload.npr.org/anon.npr-podcasts/podcast/344098539/372126500/npr_372126500.mp3"; | |
} | |
} | |
List audioEntityList = new ArrayList(); | |
audioEntityList.add(audioEntity); | |
player.setAudioEntityList(audioEntityList); | |
player.show() | |
} | |
} |