Search in sources :

Example 1 with ImageInfo

use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.

the class BeamManager method playVideo.

public void playVideo(StreamInfo info, final MediaPlayer.LaunchListener listener) {
    if (!mConnected) {
        listener.onError(ServiceCommandError.getError(503));
    }
    mStreamInfo = info;
    String location = info.getStreamUrl();
    if (!location.startsWith("http")) {
        BeamServer.setCurrentVideo(location);
        location = BeamServer.getVideoURL();
    }
    String subsLocation = null;
    SubtitleWrapper subtitle = info.getSubtitle();
    if (subtitle != null && subtitle.getFileUri() != null) {
        BeamServer.setCurrentSubs(subtitle.getFileUri().getPath());
        if (mCurrentDevice.hasCapability(MediaPlayer.Subtitles_Vtt)) {
            subsLocation = BeamServer.getSubsURL(BeamServer.VTT);
        } else if (mCurrentDevice.hasCapability(MediaPlayer.Subtitles_Srt)) {
            subsLocation = BeamServer.getSubsURL(BeamServer.SRT);
        }
    } else {
        BeamServer.removeSubs();
    }
    try {
        URL url = new URL(location);
        URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
        location = uri.toString();
        if (subsLocation != null) {
            URL subsUrl = new URL(subsLocation);
            URI subsUri = new URI(subsUrl.getProtocol(), subsUrl.getUserInfo(), subsUrl.getHost(), subsUrl.getPort(), subsUrl.getPath(), subsUrl.getQuery(), subsUrl.getRef());
            subsLocation = subsUri.toString();
        }
    } catch (MalformedURLException | URISyntaxException e) {
        e.printStackTrace();
    }
    String title = info.getFullTitle();
    String imageUrl = info.getPosterImage() == null ? "https://butterproject.org/images/header-logo.png" : info.getPosterImage();
    // String url, String mimeType, String title, String description, String iconSrc, boolean shouldLoop, LaunchListener listener
    if (mCurrentDevice != null) {
        MediaInfo mediaInfo = new MediaInfo(location, subsLocation, "video/mp4", title, "");
        mediaInfo.addImages(new ImageInfo(imageUrl));
        mCurrentDevice.getCapability(MediaPlayer.class).playMedia(mediaInfo, false, new MediaPlayer.LaunchListener() {

            @Override
            public void onSuccess(MediaPlayer.MediaLaunchObject object) {
                mLaunchSession = object.launchSession;
                if (listener != null) {
                    listener.onSuccess(object);
                }
            }

            @Override
            public void onError(ServiceCommandError error) {
                Timber.e(error.getMessage());
                if (listener != null) {
                    listener.onError(error);
                }
            }
        });
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) ServiceCommandError(com.connectsdk.service.command.ServiceCommandError) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI) URL(java.net.URL) MediaInfo(com.connectsdk.core.MediaInfo) ImageInfo(com.connectsdk.core.ImageInfo) SubtitleWrapper(butter.droid.base.providers.subs.model.SubtitleWrapper) MediaPlayer(com.connectsdk.service.capability.MediaPlayer)

Example 2 with ImageInfo

use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.

the class AirPlayService method displayImage.

@Override
public void displayImage(MediaInfo mediaInfo, LaunchListener listener) {
    String mediaUrl = null;
    String mimeType = null;
    String title = null;
    String desc = null;
    String iconSrc = null;
    if (mediaInfo != null) {
        mediaUrl = mediaInfo.getUrl();
        mimeType = mediaInfo.getMimeType();
        title = mediaInfo.getTitle();
        desc = mediaInfo.getDescription();
        if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
            ImageInfo imageInfo = mediaInfo.getImages().get(0);
            iconSrc = imageInfo.getUrl();
        }
    }
    displayImage(mediaUrl, mimeType, title, desc, iconSrc, listener);
}
Also used : ImageInfo(com.connectsdk.core.ImageInfo)

Example 3 with ImageInfo

use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.

the class AirPlayService method playMedia.

@Override
public void playMedia(MediaInfo mediaInfo, boolean shouldLoop, LaunchListener listener) {
    String mediaUrl = null;
    String mimeType = null;
    String title = null;
    String desc = null;
    String iconSrc = null;
    if (mediaInfo != null) {
        mediaUrl = mediaInfo.getUrl();
        mimeType = mediaInfo.getMimeType();
        title = mediaInfo.getTitle();
        desc = mediaInfo.getDescription();
        if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
            ImageInfo imageInfo = mediaInfo.getImages().get(0);
            iconSrc = imageInfo.getUrl();
        }
    }
    playMedia(mediaUrl, mimeType, title, desc, iconSrc, shouldLoop, listener);
}
Also used : ImageInfo(com.connectsdk.core.ImageInfo)

Example 4 with ImageInfo

use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.

the class DLNAService method playMedia.

@Override
public void playMedia(MediaInfo mediaInfo, boolean shouldLoop, LaunchListener listener) {
    String mediaUrl = null;
    String subsUrl = null;
    String mimeType = null;
    String title = null;
    String desc = null;
    String iconSrc = null;
    if (mediaInfo != null) {
        mediaUrl = mediaInfo.getUrl();
        subsUrl = mediaInfo.getSubsUrl();
        mimeType = mediaInfo.getMimeType();
        title = mediaInfo.getTitle();
        desc = mediaInfo.getDescription();
        if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
            ImageInfo imageInfo = mediaInfo.getImages().get(0);
            iconSrc = imageInfo.getUrl();
        }
    }
    displayMedia(mediaUrl, subsUrl, mimeType, title, desc, iconSrc, listener);
}
Also used : ImageInfo(com.connectsdk.core.ImageInfo)

Example 5 with ImageInfo

use of com.connectsdk.core.ImageInfo in project butter-android by butterproject.

the class DLNAService method displayImage.

@Override
public void displayImage(MediaInfo mediaInfo, LaunchListener listener) {
    String mediaUrl = null;
    String mimeType = null;
    String title = null;
    String desc = null;
    String iconSrc = null;
    if (mediaInfo != null) {
        mediaUrl = mediaInfo.getUrl();
        mimeType = mediaInfo.getMimeType();
        title = mediaInfo.getTitle();
        desc = mediaInfo.getDescription();
        if (mediaInfo.getImages() != null && mediaInfo.getImages().size() > 0) {
            ImageInfo imageInfo = mediaInfo.getImages().get(0);
            iconSrc = imageInfo.getUrl();
        }
    }
    displayImage(mediaUrl, mimeType, title, desc, iconSrc, listener);
}
Also used : ImageInfo(com.connectsdk.core.ImageInfo)

Aggregations

ImageInfo (com.connectsdk.core.ImageInfo)18 MediaInfo (com.connectsdk.core.MediaInfo)4 ServiceCommandError (com.connectsdk.service.command.ServiceCommandError)2 ArrayList (java.util.ArrayList)2 SubtitleWrapper (butter.droid.base.providers.subs.model.SubtitleWrapper)1 RemoteMediaPlayer (com.amazon.whisperplay.fling.media.controller.RemoteMediaPlayer)1 MediaPlayerInfo (com.amazon.whisperplay.fling.media.service.MediaPlayerInfo)1 MediaPlayer (com.connectsdk.service.capability.MediaPlayer)1 FireTVServiceError (com.connectsdk.service.command.FireTVServiceError)1 MediaMetadata (com.google.android.gms.cast.MediaMetadata)1 MalformedURLException (java.net.MalformedURLException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 URL (java.net.URL)1 List (java.util.List)1 ExecutionException (java.util.concurrent.ExecutionException)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1