Skip to content
This repository has been archived by the owner on Apr 3, 2020. It is now read-only.

[Android] Support third part media player on Crosswalk #3736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fujunwei
Copy link
Contributor

@fujunwei fujunwei commented Jun 3, 2016

A requirement from an important customer who want to forward web resources with proxy
on Crosswalk, but android system MediaPlayer can't set a proxy with a standard API.
The ExoMediaPlayer is playing videos and music is a popular activity on Android devices,
and it can be configured with proxy.
https://developer.android.com/guide/topics/media/exoplayer.html

BUG=XWALK-6770

@crosswalk-trybot
Copy link

crosswalk-trybot commented Jun 3, 2016

Testing patch series with fujunwei/crosswalk@024bae0 as its head.

Bot Status
Crosswalk Android-X86 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android-X86/builds/4531)
Crosswalk Android x86-64 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android x86-64/builds/1579)
Crosswalk Linux [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux/builds/4521)

@@ -862,6 +862,13 @@ public void setResourceClient(XWalkResourceClientInternal client) {
mContent.setResourceClient(client);
}

@XWalkAPI(reservable = true)
public void setExMediaPlayer(XWalkExMediaPlayerInternal mediaPlayer) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add the comment for this API?

@fujunwei
Copy link
Contributor Author

fujunwei commented Jun 3, 2016

Thanks @wuhengzhi Those proposals will be modified one by one.

@@ -9,11 +9,13 @@
import android.media.MediaPlayer;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it?

@sunlin-link
Copy link
Contributor

One thing, I'm still confused by the name ExMediaPlayer. Can we use a more intuitive name instead of some abbreviations?

@crosswalk-trybot
Copy link

crosswalk-trybot commented Jun 27, 2016

Testing patch series with fujunwei/crosswalk@9baa6c1 as its head.

Bot Status
Crosswalk Android-X86 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android-X86/builds/4564)
Crosswalk Android x86-64 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android x86-64/builds/1612)
Crosswalk Linux [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux/builds/4554)

@fujunwei
Copy link
Contributor Author

Changed ExMediaPlayer to ExternalMediaPlayer that is used in native code. Developer will use XWalkMediaPlayer to implement third party Media Player.
@lincsoon @xuxin @wuhengzhi PTAL.

}

/**
* Sets the data source (FileDescriptor) to use.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lack of first parameter

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@param fd the FileDescriptor for the file you want to play.

@crosswalk-trybot
Copy link

crosswalk-trybot commented Jun 28, 2016

Testing patch series with fujunwei/crosswalk@18f4196 as its head.

Bot Status
Crosswalk Android-X86 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android-X86/builds/4568)
Crosswalk Android x86-64 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android x86-64/builds/1616)
Crosswalk Linux [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux/builds/4558)


/**
* Sets the volume on this player.
* @since 7.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing the explanation for parameters.

}

/**
* Register a callback to be invoked when the end of a media source has been reached during playback.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment is too long.

@sunlin-link
Copy link
Contributor

@fujunwei What's the latest status?

@crosswalk-trybot
Copy link

crosswalk-trybot commented Aug 9, 2016

Testing patch series with fujunwei/crosswalk@9f6fdcd as its head.

Bot Status
Crosswalk Android-X86 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android-X86/builds/4680)
Crosswalk Android x86-64 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android x86-64/builds/1728)
Crosswalk Linux [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux/builds/4670)

@crosswalk-trybot
Copy link

crosswalk-trybot commented Aug 10, 2016

Testing patch series with fujunwei/crosswalk@354a041 as its head.

Bot Status
Crosswalk Android-X86 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android-X86/builds/4681)
Crosswalk Android x86-64 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android x86-64/builds/1729)
Crosswalk Linux [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux/builds/4671)

@fujunwei
Copy link
Contributor Author

PTAL.

@crosswalk-trybot
Copy link

crosswalk-trybot commented Aug 31, 2016

Testing patch series with fujunwei/crosswalk@1dcd337 as its head.

Bot Status
Crosswalk Linux GN [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux GN/builds/2)
Crosswalk Android-X86 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android-X86/builds/4725)
Crosswalk Android x86-64 [FAILED 💔](https://build.crosswalk-project.org/try/builders/Crosswalk Android x86-64/builds/1775)
Crosswalk Linux [SUCCESS 💚](https://build.crosswalk-project.org/try/builders/Crosswalk Linux/builds/4715)

A requirement from an important customer who want to forward web resources with proxy
on Crosswalk, but android system MediaPlayer can't set a proxy with a standard API.
The ExoMediaPlayer is playing videos and music is a popular activity on Android devices,
and it can be configured with proxy.
https://developer.android.com/guide/topics/media/exoplayer.html

BUG=XWALK-6770
@LukePulverenti
Copy link

Does this support overlaying html content over the video surface just the same as the built-in player?

@axinging
Copy link
Contributor

axinging commented Feb 6, 2017 via email

@LukePulverenti
Copy link

Well I'd like to do both. I want to use a custom video player based on these changes, and I want to be able to overlay html content over the video element as per normal.

@Sailiy
Copy link

Sailiy commented Jul 16, 2017

我切换到new_exo_media_player分支并编译成了aar导入我的项目,请问xwalkview.setXWalkMediaPlayer() 这个API该如何使用。我尝试直接new XWalkMediaPlayer()或继承它实现自己的MyMediaPlayer,最终都报NullPointerException异常。导致app崩溃。

public class MainActivity extends AppCompatActivity {
    private XWalkView webview;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        webview = (XWalkView) findViewById(R.id.webview);
        XWalkPreferences.setValue(XWalkPreferences.REMOTE_DEBUGGING, true);
        webview.getSettings().setJavaScriptEnabled(true);
        XWalkMediaPlayer myMediaPlayer = new XWalkMediaPlayer();
//        MyMediaPlayer myMediaPlayer = new MyMediaPlayer();
        webview.setXWalkMediaPlayer(myMediaPlayer);
    }
    @Override
    protected void onResume() {
        super.onResume();
        webview.load("http://www.baidu.com",null);
    }
}

报错如下:

FATAL EXCEPTION: main
   Process: zy.com.xwalkvideo, PID: 23341
   java.lang.RuntimeException: Unable to start activity ComponentInfo{zy.com.xwalkvideo/zy.com.xwalkvideo.MainActivity}: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.xwalk.core.internal.ReflectMethod.isNull()' on a null object reference
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2676)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2745)
       at android.app.ActivityThread.access$900(ActivityThread.java:181)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1596)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:194)
       at android.app.ActivityThread.main(ActivityThread.java:5860)
       at java.lang.reflect.Method.invoke(Native Method)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)
    Caused by: java.lang.RuntimeException: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.xwalk.core.internal.ReflectMethod.isNull()' on a null object reference
       at org.xwalk.core.ReflectConstructor.newInstance(ReflectConstructor.java:54)
       at org.xwalk.core.XWalkMediaPlayer.reflectionInit(XWalkMediaPlayer.java:1020)
       at org.xwalk.core.XWalkMediaPlayer.<init>(XWalkMediaPlayer.java:52)
       at zy.com.xwalkvideo.MyMediaPlayer.<init>(MyMediaPlayer.java:11)
       at zy.com.xwalkvideo.MainActivity.onCreate(MainActivity.java:21)
       at android.app.Activity.performCreate(Activity.java:6127)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2629)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2745) 
       at android.app.ActivityThread.access$900(ActivityThread.java:181) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1596) 
       at android.os.Handler.dispatchMessage(Handler.java:111) 
       at android.os.Looper.loop(Looper.java:194) 
       at android.app.ActivityThread.main(ActivityThread.java:5860) 
       at java.lang.reflect.Method.invoke(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:372) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814) 
    Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean org.xwalk.core.internal.ReflectMethod.isNull()' on a null object reference
       at org.xwalk.core.internal.XWalkMediaPlayerBridge.getCurrentPosition(XWalkMediaPlayerBridge.java:176)
       at android.media.MediaPlayer$TimeProvider.getCurrentTimeUs(MediaPlayer.java:3756)
       at android.media.MediaPlayer$TimeProvider.<init>(MediaPlayer.java:3460)
       at android.media.MediaPlayer.<init>(MediaPlayer.java:637)
       at org.xwalk.core.internal.XWalkMediaPlayerInternal.<init>(XWalkMediaPlayerInternal.java:33)
       at org.xwalk.core.internal.XWalkMediaPlayerBridge.<init>(XWalkMediaPlayerBridge.java:40)
       at java.lang.reflect.Constructor.newInstance(Native Method)
       at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
       at org.xwalk.core.ReflectConstructor.newInstance(ReflectConstructor.java:48)
       at org.xwalk.core.XWalkMediaPlayer.reflectionInit(XWalkMediaPlayer.java:1020) 
       at org.xwalk.core.XWalkMediaPlayer.<init>(XWalkMediaPlayer.java:52) 
       at zy.com.xwalkvideo.MyMediaPlayer.<init>(MyMediaPlayer.java:11) 
       at zy.com.xwalkvideo.MainActivity.onCreate(MainActivity.java:21) 
       at android.app.Activity.performCreate(Activity.java:6127) 
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123) 
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2629) 
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2745) 
       at android.app.ActivityThread.access$900(ActivityThread.java:181) 
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1596) 
       at android.os.Handler.dispatchMessage(Handler.java:111) 
       at android.os.Looper.loop(Looper.java:194) 
       at android.app.ActivityThread.main(ActivityThread.java:5860) 
       at java.lang.reflect.Method.invoke(Native Method) 
       at java.lang.reflect.Method.invoke(Method.java:372) 
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1019) 
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:814)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants