OwnMediaPlayer is a library designed to upload videos easily and simply. It is built with Media3 of Android. The notification part has been used following the MediaControls guide.
In the current version it supports:
OwnMediaPlayer | OwnVideoPlayerDialog | |
---|---|---|
URL | ✅ | ✅ |
URI | ✅ | ✅ |
Resource | ❌ | ✅ |
Youtube | ❌ | ❌ |
🗈 We are working to make it work in the future with many more formats and forms.
This setting is required if you want it to work correctly with notifications
⚠️ If you don't do it, it won't work properly.
In the AndroidManifest.xml of your activity, you have to add these 2 permissions:
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE_MEDIA_PLAYBACK" />
And add the media service for the notification
<service
android:name="com.danwolve.own_media_player.service.MediaService"
android:description="@string/servicio_para_mostrar_audio_saliente_museos"
android:exported="true"
android:foregroundServiceType="mediaPlayback">
<intent-filter>
<action android:name="androidx.media3.session.MediaSessionService" />
</intent-filter>
</service>
OwnMediaPlayer has been used at the moment mainly for the OwnMediaPlayerDialog part, so it is hardly complete and will be updated as the versions go by.
An example of implementation would be the following:
<com.danwolve.own_media_player.views.OwnMediaPlayer
android:id="@+id/own_media_player"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:hasNotification="true"
app:titleNotification="weapon"
app:authorNotification="Against the Current"
app:photoNotification="@drawable/aganist_the_current"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
This part is used to customize the notification.
app:hasNotification="true"
app:titleNotification="weapon"
app:authorNotification="Against the Current"
app:photoNotification="@drawable/aganist_the_current" '''
The most basic implementation would be as follows, this will load the video automatically:
binding.ownMediaPlayer.setVideoUrl("your_url.mp4")
The result with the notification will be the following, depending on the API it will be displayed in one way or another, there is a great variety of notifications, these are some examples:
API 26
API 33
OwnVideoPlayerDialog has been used at the moment mainly for the OwnMediaPlayerDialog part, so it is hardly complete and will be updated as the versions go by.
The main thing about this version currently, you can show a dialog with the video. You cannot display more than one dialog at a time.
An example of implementation would be the following:
OwnVideoPlayerDialog.Builder
.setUrl("your_url.mp4")
.activeNotification(
"weapon",
"Against the Current",
"your_image.png")
.build()
.show(supportFragmentManager, TAG)
When activating the notification, no field is mandatory, it simply will not be displayed.
If activeNotification()
is not used, no notification will be shown.
OwnMediaPlayer is available under the MIT license. Read the LICENSE.txt file for more information.