Sha256: 7308023bc79216d545f26a6ddaa90598ad22cbfbf7fa942c82578c354bc1ddff

Contents?: true

Size: 1.94 KB

Versions: 22

Compression:

Stored size: 1.94 KB

Contents

package com.rhomobile.rhodes.nativeview;

import com.rhomobile.rhodes.Logger;

import android.media.MediaPlayer;
import android.media.MediaPlayer.OnCompletionListener;
import android.media.MediaPlayer.OnErrorListener;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebChromeClient.CustomViewCallback;
import android.widget.VideoView;

public class RhoVideoView implements IRhoCustomView, OnCompletionListener, OnErrorListener {
    private static final String TAG = RhoVideoView.class.getSimpleName();
    
    private ViewGroup mCustomView;
    private VideoView mVideoView;
    private WebChromeClient.CustomViewCallback mCustomViewCallback;

    public RhoVideoView(ViewGroup view, CustomViewCallback viewCallback) {
        mCustomView = view;
        mVideoView = (VideoView)view.getFocusedChild();
        mCustomViewCallback = viewCallback;
        
        mVideoView.setOnCompletionListener(this);
        mVideoView.setOnErrorListener(this);
    }
    
    @Override
    public boolean onError(MediaPlayer mp, int what, int extra) {
        Logger.E(TAG, "Media player error: " + ((what == MediaPlayer.MEDIA_ERROR_SERVER_DIED) ? "media server died" : "unknown"));
        return false;
    }

    @Override
    public void onCompletion(MediaPlayer player) {
        player.stop();
    }

    @Override
    public View getView() {
        return mVideoView;
    }

    @Override
    public ViewGroup getContainerView() {
        return mCustomView;
    }

    @Override
    public void navigate(String url) {
        mVideoView.setVideoURI(Uri.parse(url));
        mVideoView.start();
    }

    @Override
    public void stop() {
        mVideoView.stopPlayback();
    }

    @Override
    public void destroyView() {
        mVideoView.stopPlayback();
        mCustomViewCallback.onCustomViewHidden();
    }

    @Override
    public String getViewType() {
        return "";
    }

}

Version data entries

22 entries across 22 versions & 2 rubygems

Version Path
rhodes-7.6.0 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-7.5.1 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-7.4.1 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-7.1.17 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-6.2.0 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-6.0.11 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.18 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.17 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.15 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.0.22 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.2 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.0.7 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.0.3 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-5.5.0 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
tauplatform-1.0.3 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
tauplatform-1.0.2 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
tauplatform-1.0.1 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-3.5.1.12 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-3.3.5 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java
rhodes-3.4.2 platform/android/Rhodes/src/com/rhomobile/rhodes/nativeview/RhoVideoView.java