答案 0 :(得分:3)
您需要告诉它为您的媒体文件提供服务。在urls.py
:
from django.conf import settings
if settings.DEBUG == False:
urlpatterns += patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.MEDIA_ROOT,
}),
url(r'^static/(?P<path>.*)$', 'django.views.static.serve', {
'document_root': settings.STATIC_ROOT,
}),
)
答案 1 :(得分:0)
写:
class MainActivity : AppCompatActivity() {
private val player: SimpleExoPlayer by lazy { SimpleExoPlayer.Builder(applicationContext).build() }
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
player.preparePlayer(playerView, playerViewFullscreen)
player.setSource(applicationContext, "http://html5videoformatconverter.com/data/images/happyfit2.mp4")
player.playWhenReady = true
}
public override fun onPause() {
super.onPause()
player.playWhenReady = false
}
public override fun onDestroy() {
player.release()
super.onDestroy()
}
}
然后在import re
from urllib.parse import urlsplit
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.urls import re_path
from django.views.static import serve
def static(prefix, view=serve, **kwargs):
return [
re_path(r'^%s(?P<path>.*)$' % re.escape(prefix.lstrip('/')), view, kwargs=kwargs),
]
中输入
urls.py