Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
SDK
/
exoplayer
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
8ea3f980
authored
Oct 01, 2014
by
ojw28
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Add class to enable loading of out-of-band subtitle files.
parent
dd30632a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
108 additions
and
0 deletions
library/src/main/java/com/google/android/exoplayer/chunk/SingleSampleChunkSource.java
library/src/main/java/com/google/android/exoplayer/chunk/SingleSampleChunkSource.java
0 → 100644
View file @
8ea3f980
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
com
.
google
.
android
.
exoplayer
.
chunk
;
import
com.google.android.exoplayer.MediaFormat
;
import
com.google.android.exoplayer.TrackInfo
;
import
com.google.android.exoplayer.upstream.DataSource
;
import
com.google.android.exoplayer.upstream.DataSpec
;
import
java.io.IOException
;
import
java.util.List
;
/**
* A chunk source that provides a single chunk containing a single sample.
* <p>
* An example use case for this implementation is to act as the source for loading out-of-band
* subtitles, where subtitles for the entire video are delivered as a single file.
*/
public
class
SingleSampleChunkSource
implements
ChunkSource
{
private
final
DataSource
dataSource
;
private
final
DataSpec
dataSpec
;
private
final
Format
format
;
private
final
long
durationUs
;
private
final
MediaFormat
mediaFormat
;
private
final
TrackInfo
trackInfo
;
/**
* @param dataSource A {@link DataSource} suitable for loading the sample data.
* @param dataSpec Defines the location of the sample.
* @param format The format of the sample.
* @param durationUs The duration of the sample in microseconds.
* @param mediaFormat The sample media format. May be null.
*/
public
SingleSampleChunkSource
(
DataSource
dataSource
,
DataSpec
dataSpec
,
Format
format
,
long
durationUs
,
MediaFormat
mediaFormat
)
{
this
.
dataSource
=
dataSource
;
this
.
dataSpec
=
dataSpec
;
this
.
format
=
format
;
this
.
durationUs
=
durationUs
;
this
.
mediaFormat
=
mediaFormat
;
trackInfo
=
new
TrackInfo
(
format
.
mimeType
,
durationUs
);
}
@Override
public
TrackInfo
getTrackInfo
()
{
return
trackInfo
;
}
@Override
public
void
getMaxVideoDimensions
(
MediaFormat
out
)
{
// Do nothing.
}
@Override
public
void
enable
()
{
// Do nothing.
}
@Override
public
void
continueBuffering
(
long
playbackPositionUs
)
{
// Do nothing.
}
@Override
public
void
getChunkOperation
(
List
<?
extends
MediaChunk
>
queue
,
long
seekPositionUs
,
long
playbackPositionUs
,
ChunkOperationHolder
out
)
{
if
(!
queue
.
isEmpty
())
{
// We've already provided the single sample.
return
;
}
out
.
chunk
=
initChunk
();
}
@Override
public
void
disable
(
List
<?
extends
MediaChunk
>
queue
)
{
// Do nothing.
}
@Override
public
IOException
getError
()
{
return
null
;
}
@Override
public
void
onChunkLoadError
(
Chunk
chunk
,
Exception
e
)
{
// Do nothing.
}
private
SingleSampleMediaChunk
initChunk
()
{
return
new
SingleSampleMediaChunk
(
dataSource
,
dataSpec
,
format
,
0
,
0
,
durationUs
,
-
1
,
mediaFormat
);
}
}
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