Created
June 24, 2018 13:42
-
-
Save GrakovNe/5fec2e7db7fcf20dbf7b670fe3386b55 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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