Skip to content

Instantly share code, notes, and snippets.

@GrakovNe
Created June 24, 2018 13:42
Show Gist options
  • Select an option

  • Save GrakovNe/5fec2e7db7fcf20dbf7b670fe3386b55 to your computer and use it in GitHub Desktop.

Select an option

Save GrakovNe/5fec2e7db7fcf20dbf7b670fe3386b55 to your computer and use it in GitHub Desktop.
package org.grakovne.mds.android.media;
import android.content.Context;
import org.grakovne.mds.android.common.ActionNames.Player;
import org.grakovne.mds.android.manager.BroadcastManager;
import java.io.IOException;
import static org.grakovne.mds.android.utils.NetworkUtils.findStoryUrl;
public class NetworkPlayer extends StoryPlayer {
public NetworkPlayer(Context context, DataSource dataSource) {
super(context, dataSource);
}
@Override
public String toUri(DataSource source) {
return findStoryUrl(source);
}
@Override
void feedDataSource() {
mediaPlayer.setOnPreparedListener(mediaPlayer -> BroadcastManager.send(context, Player.PREPARED_EVENT));
try {
mediaPlayer.setDataSource(toUri(dataSource));
mediaPlayer.prepareAsync();
} catch (IOException e) {
BroadcastManager.send(context, Player.STOPPED_EVENT);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment