1

I am trying to launch media player to play an HLS link from kivy+android environment. I am able to launch the default media player using the sample code I got from net (given below). But I have installed another better media player (https://play.google.com/store/apps/details?id=veg.network.mediaplayer) that I want to be launched with the url. Any idea how I can proceed on this? Is it possible to create intents from kivy? (Note: I am using kivy launcher and not apk (buildozer))

from jnius import autoclass
from time import sleep

# get the MediaPlayer java class
MediaPlayer = autoclass('android.media.MediaPlayer')
#MediaPlayer = autoclass('veg.network.mediaplayer')
# create our player
mPlayer = MediaPlayer()
mPlayer.setDataSource('http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8')
mPlayer.prepare()

# play
print 'duration:', mPlayer.getDuration()
mPlayer.start()
print 'current position:', mPlayer.getCurrentPosition()
sleep(50)

# then after the play:
mPlayer.release()

thx, gl

user2148707
  • 93
  • 12

1 Answers1

2

Yes, you can create intents from Kivy the same way you access other Java classes. Maybe something like this:

PythonActivity = autoclass('org.renpy.android.PythonActivity')
Intent = autoclass('android.content.Intent')
Uri = autoclass('android.net.Uri')
media_intent = Intent(Intent.ACTION_VIEW)
uri = Uri.parse('http://www.nasa.gov/multimedia/nasatv/NTV-Public-IPS.m3u8')
media_intent.setDataAndType(uri, 'video/*')
PythonActivity.mActivity.startActivity(media_intent)
kitti
  • 14,663
  • 31
  • 49