Skip to content

Commit

Permalink
fix: null width and height event (#147)
Browse files Browse the repository at this point in the history
fix #145
  • Loading branch information
befovy authored Dec 20, 2019
1 parent 4e9e306 commit 3bcae22
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
5 changes: 4 additions & 1 deletion android/src/main/java/com/befovy/fijkplayer/FijkPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -241,13 +241,16 @@ private void handleEvent(int what, int arg1, int arg2, Object extra) {
if (mRotate == 0 || mRotate == 180) {
event.put("width", arg1);
event.put("height", arg2);
mEventSink.success(event);
} else if (mRotate == 90 || mRotate == 270) {
event.put("width", arg2);
event.put("height", arg1);
mEventSink.success(event);
}
// default mRotate is -1 which means unknown
// do not send event if mRotate is unknown
mWidth = arg1;
mHeight = arg2;
mEventSink.success(event);
break;
case ERROR:
mEventSink.error(String.valueOf(arg1), extra.toString(), arg2);
Expand Down
31 changes: 26 additions & 5 deletions go/go-player.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ const (
)

type FijkPlayer struct {
id int32
state int32
id int32
state int32
rotate int32
width int32
height int32

ijk *ijkplayer

Expand Down Expand Up @@ -101,6 +104,7 @@ func (f *FijkPlayer) initPlayer(messenger plugin.BinaryMessenger, tex *flutter.T

f.id = atomic.AddInt32(&atomicId, 1)
f.state = idle
f.rotate = -1
f.texRegistry = tex
f.sink = &queueEventSink{}

Expand Down Expand Up @@ -440,11 +444,28 @@ func (f *FijkPlayer) handleEvent(what int, arg1, arg2 int32, extra interface{})
event["percent"] = arg2
f.sink.success(event)
break
case IJKMPET_VIDEO_ROTATION_CHANGED:
event["event"] = "rotate"
event["degree"] = arg1
f.sink.success(event)
f.rotate = arg1
if f.height > 0 && f.width > 0 {
f.handleEvent(IJKMPET_VIDEO_SIZE_CHANGED, f.width, f.height, nil)
}
break
case IJKMPET_VIDEO_SIZE_CHANGED:
event["event"] = "size_changed"
event["width"] = arg1
event["height"] = arg2
f.sink.success(event)
if f.rotate == 0 || f.rotate == 90 {
event["width"] = arg1
event["height"] = arg2
f.sink.success(event)
} else if f.rotate == 90 || f.rotate == 270 {
event["width"] = arg2
event["height"] = arg1
f.sink.success(event)
}
f.width = arg1
f.height = arg2
break
case IJKMPET_ERROR:
str := ""
Expand Down

0 comments on commit 3bcae22

Please sign in to comment.