Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Thomas
Fedilab
Commits
a0563ce4
Commit
a0563ce4
authored
May 17, 2020
by
Thomas
Browse files
Fix for videos
parent
129621c7
Pipeline
#302395
passed with stage
in 9 minutes and 22 seconds
Changes
4
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
app/src/main/java/app/fedilab/android/activities/PeertubeActivity.java
View file @
a0563ce4
...
...
@@ -559,7 +559,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
videoSource
=
new
ProgressiveMediaSource
.
Factory
(
dataSourceFactory
)
.
createMediaSource
(
Uri
.
parse
(
apiResponse
.
getPeertubes
().
get
(
0
).
getFileUrl
(
null
,
apiResponse
.
getPeertubes
().
get
(
0
).
isStreamService
())));
}
else
{
CacheDataSourceFactory
cacheDataSourceFactory
=
new
CacheDataSourceFactory
(
PeertubeActivity
.
this
,
video_cache
*
1024
*
1024
,
5
*
1024
*
1024
);
CacheDataSourceFactory
cacheDataSourceFactory
=
new
CacheDataSourceFactory
(
PeertubeActivity
.
this
);
videoSource
=
new
ProgressiveMediaSource
.
Factory
(
cacheDataSourceFactory
)
.
createMediaSource
(
Uri
.
parse
(
apiResponse
.
getPeertubes
().
get
(
0
).
getFileUrl
(
null
,
apiResponse
.
getPeertubes
().
get
(
0
).
isStreamService
())));
}
...
...
@@ -767,7 +767,7 @@ public class PeertubeActivity extends BaseActivity implements OnRetrievePeertube
videoSource
=
new
ProgressiveMediaSource
.
Factory
(
dataSourceFactory
)
.
createMediaSource
(
Uri
.
parse
(
peertube
.
getFileUrl
(
res
,
peertube
.
isStreamService
())));
}
else
{
CacheDataSourceFactory
cacheDataSourceFactory
=
new
CacheDataSourceFactory
(
PeertubeActivity
.
this
,
video_cache
*
1024
*
1024
,
5
*
1024
*
1024
);
CacheDataSourceFactory
cacheDataSourceFactory
=
new
CacheDataSourceFactory
(
PeertubeActivity
.
this
);
videoSource
=
new
ProgressiveMediaSource
.
Factory
(
cacheDataSourceFactory
)
.
createMediaSource
(
Uri
.
parse
(
peertube
.
getFileUrl
(
res
,
peertube
.
isStreamService
())));
}
...
...
app/src/main/java/app/fedilab/android/fragments/MediaSliderFragment.java
View file @
a0563ce4
...
...
@@ -263,7 +263,7 @@ public class MediaSliderFragment extends Fragment implements MediaPlayer.OnCompl
videoSource
=
new
ProgressiveMediaSource
.
Factory
(
dataSourceFactory
)
.
createMediaSource
(
uri
);
}
else
{
CacheDataSourceFactory
cacheDataSourceFactory
=
new
CacheDataSourceFactory
(
context
,
video_cache
*
1024
*
1024
,
5
*
1024
*
1024
);
CacheDataSourceFactory
cacheDataSourceFactory
=
new
CacheDataSourceFactory
(
context
);
videoSource
=
new
ProgressiveMediaSource
.
Factory
(
cacheDataSourceFactory
)
.
createMediaSource
(
uri
);
}
...
...
app/src/main/java/app/fedilab/android/helper/CacheDataSourceFactory.java
View file @
a0563ce4
...
...
@@ -18,15 +18,15 @@ import java.io.File;
public
class
CacheDataSourceFactory
implements
DataSource
.
Factory
{
private
static
SimpleCache
sDownloadCache
;
private
final
Context
context
;
private
final
DefaultDataSourceFactory
defaultDatasourceFactory
;
private
final
long
maxFileSize
,
maxCacheSize
;
private
final
long
maxFileSize
;
public
CacheDataSourceFactory
(
Context
context
,
long
maxCacheSize
,
long
maxFileSize
)
{
public
CacheDataSourceFactory
(
Context
context
)
{
super
();
this
.
context
=
context
;
this
.
maxCacheSize
=
maxCacheSize
;
this
.
maxFileSize
=
maxFileSize
;
this
.
maxFileSize
=
5
*
1024
*
1024
;
SharedPreferences
sharedpreferences
=
context
.
getSharedPreferences
(
Helper
.
APP_PREFS
,
Context
.
MODE_PRIVATE
);
String
userAgent
=
sharedpreferences
.
getString
(
Helper
.
SET_CUSTOM_USER_AGENT
,
Helper
.
USER_AGENT
);
DefaultBandwidthMeter
.
Builder
bandwidthMeterBuilder
=
new
DefaultBandwidthMeter
.
Builder
(
context
);
...
...
@@ -36,11 +36,19 @@ public class CacheDataSourceFactory implements DataSource.Factory {
new
DefaultHttpDataSourceFactory
(
userAgent
,
bandwidthMeter
));
}
public
static
SimpleCache
getInstance
(
Context
context
)
{
SharedPreferences
sharedpreferences
=
context
.
getSharedPreferences
(
Helper
.
APP_PREFS
,
Context
.
MODE_PRIVATE
);
int
video_cache
=
sharedpreferences
.
getInt
(
Helper
.
SET_VIDEO_CACHE
,
Helper
.
DEFAULT_VIDEO_CACHE_MB
);
LeastRecentlyUsedCacheEvictor
evictor
=
new
LeastRecentlyUsedCacheEvictor
(
video_cache
*
1024
*
1024
);
ExoDatabaseProvider
exoDatabaseProvider
=
new
ExoDatabaseProvider
(
context
);
if
(
sDownloadCache
==
null
)
sDownloadCache
=
new
SimpleCache
(
new
File
(
context
.
getCacheDir
(),
"media"
),
evictor
,
exoDatabaseProvider
);
return
sDownloadCache
;
}
@Override
public
DataSource
createDataSource
()
{
LeastRecentlyUsedCacheEvictor
evictor
=
new
LeastRecentlyUsedCacheEvictor
(
maxCacheSize
);
ExoDatabaseProvider
exoDatabaseProvider
=
new
ExoDatabaseProvider
(
context
);
SimpleCache
simpleCache
=
new
SimpleCache
(
new
File
(
context
.
getCacheDir
(),
"media"
),
evictor
,
exoDatabaseProvider
);
SimpleCache
simpleCache
=
getInstance
(
context
);
return
new
CacheDataSource
(
simpleCache
,
defaultDatasourceFactory
.
createDataSource
(),
new
FileDataSource
(),
new
CacheDataSink
(
simpleCache
,
maxFileSize
),
CacheDataSource
.
FLAG_BLOCK_ON_CACHE
|
CacheDataSource
.
FLAG_IGNORE_CACHE_ON_ERROR
,
null
);
...
...
app/src/main/java/app/fedilab/android/services/LiveNotificationService.java
View file @
a0563ce4
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment